Short Description

The Simple Moving Average (or SMA) indicator calculates the average price over a specific number of periods.


instrument - defines Instrument of bars used as indicator data source.

period - defines Period of bars used as indicator data source.

shift - Defines which bar the indicator is calculated for: 0 - current unformed bar, 1 - previous bar and so on. Is of type Integer.

Time Period Integer - number of bars used in calculation.

Line Double - Indicator output (the result of indicator calculation).

IndicatorCall - connects indicator block with other blocks to continue the flow of Visual JForex strategy.

Main Description

General description

One of the basic and popular types of Moving Averages - a simple moving average is calculated by computing the average price over a specified number of periods.

Simple moving average is a so called lagging indicator, since it is calculated using past prices (calculation is generally based on closing prices).

Despite this lag, moving averages help smooth price action and filter out the noise.

This indicator may be used as support-resistance level and help identify the direction of trend.

A cross of long-term and short-term moving averages is a popular way of identifying a trend change.

SMA is calculated using the following formula: ΣPn/n, where n is the number of periods, or bars to calculate the SMA over, and Pn is the price for period n.

SMA in Visual JForex

SMA block is located in the Indicator section under the MA category. Drag and drop the block on the board, connect it with another block or click and create a variable of type Double to store the calculation result.

Input variables are used to set up indicator for calculation, things like range of values (prices) used in calculation, timeframe (10 Mins, 1 Hour, etc), Instrument and so on.

Output values (or variables) store the result of indicator calculation. These variables may later be referenced from another blocks like, for example, logical expressions that result in trading decisions made by the Visual JForex strategy.

The settings section of SMA block contains offerside (Bid or Ask) and applied price (Open, Close, etc) settings.

Instrument, Period, OfferSide and AppliedPrice together describe the source of SMA indicator input data.

The following visual strategies use SMA in their logic: SMA Cross Example, SMA Cross Example strategy. These strategies are based on cross of two SMA indicators.