VTrend3_5_3 is a swing trading strategy, which performs best on
trending pairs with long (500+ pips) swings.
Input parameters:
defaultInstrument : GBP/JPY - Instrument
defaultTradeAmount : 3.0 - Trade amount in millions
defaultSlippage : 10 - Slippage in pips
defaultStopLoss : 133 - Stop loss in pips
defaultTakeProfit : 990 - Take profit in pips
defaultPeriod : H1 - Time period
maxSpread : 10.0 - Max spread in pips
entryHour1 : 0 - Entry hour #1 (GMT)
entryHour2 : 1 - Entry hour #2 (GMT)
maPeriod : 5 - Time period of daily exponential moving average
(EMA)
Trading logic:
Starts execution in onCandle.
Continues only if last (bid) candle period equals defaultPeriod and
instrument equals defaultInstrument.
Calculates day of week and continues only if it is not equal to 1
(Sunday) and 7 (Saturday).
Calculates spread and continues only if spread is lower or equal than
maxSpread.
Updates currentDay and currentHour variables. Continues if currentHour
is equal to entryHour1 and currentDay is not equal to day1. Also
continues if currentHour is equal to entryHour2 and currentDay is not
equal to day2.
Closes open position, if there is one.
Calculates amount: amount = min(Equity/20000.0, defaultTradeAmount).
Calculates ema0 (EMA(maPeriod) for two days back) and ema1
(EMA(maPeriod) for one day back).
If ema0 is lower than or equal to ema1 then opens long position with
defaultInstrument, amount, defaultSlippage, defaultStopLoss,
defaultTakeProfit.
If ema0 is greater than ema1 then opens short position with
defaultInstrument, amount, defaultSlippage, defaultStopLoss,
defaultTakeProfit.
Continues only if order submit was ok.
If currentHour equals entryHour1 it sets day1 variable to value of
currentDay and returns.
If currentHour equals entryHour2 it sets day2 variable to value of
currentDay and returns.