Blocks

Short Description

A SMASCross Users Strategy makes trades based on the SMA indicator. The Strategy located in a Trend subcategory.

Tooltips

defaultPeriod - SMA indicator period, default value 10(configurable).

defaultSlippage - Slippage value for orders in the strategy, default value 25(configurable).

defaultTakeProfit - Orders take profit value, default value 50(configurable)

defaultStopLoss - Orders stop loss value, default value 25(configurable)

defaultTradeAmount - Order amount in millions. Default value 0.001(configurable).

defaultInstrument - Instrument for orders and the Sma indicator value. Default EUR/USD(configurable).

Main Description

Main Definition.

The SmaCross Users Strategy makes trades based on two Simple Moving Average (SMA) lines crossing. First line is "Fast" SMA with time period 10, second line is "Slow" SMA with time period 30. If SMA 10 line crosses SMA 30 line from up to down, then the strategy opens a buy order, otherwise if SMA 10 crosses line SMA 30 line from down to up, then the strategy opens a sell order. For storing several data like SMA indicator value, indicator period, take proffit value e.t.c the strategy needs Variable's.

Variables.

The SmaCross Users strategy has 4 variables to store last and previous candle Fast/Slow SMA values, also 6 default variable described above in the Tooltips section.

  • smaBigCurrent - Variable for storing current Candle slow(Big) SMA indicator value.
  • smaBigPrev - Variable for storing previous candle slow SMA indicator value.
  • smaSmallCurrent - Variable for storing current Candle fast(Small) SMA indicator value.
  • smaSmallPrev   - Variable for storing previous Candle fast SMA indicator value.

Trade.

After saving variables, the strategy needs to check the SMA indicator lines crossing by using the If  block, it checks fast Sma crossing slow Sma line from up to down condition. If condition matches, the strategy goes Long(open Buy Order), otherwise goes Short.

The Strategy closes position by stop loss or take profit, please take a look description of the defaultStopLoss and the defaultTakeProfit variables in a Open at Market block.

Run and Test.

To check the strategy we can run it like block(just putting it on the board) or right click on the Sma Cross User strategy in the left panel, click Load VFS and you will see all strategy blocks. After that, press run button  and choose Realtime or Historical runtime mode. In the historical runtime mode result will be similar with this image:

We can see from above image that after fast sma line crossed slow line, the strategy opened a buy order and closed it after the take proffit triggered, then after fast SMA crossed slow from up to down, the strategy created a Sell order, but closed it on the stop loss value.

Please see the SmaCross Users strategy in a Visual JForex interface.

Open file:

Download file: