I'm trying to design a simple strategy for Crude Oil Futures using a combination of Renko 6 and Heikin Ashi Candles but when I backtest it I just can manage to understand why it's not performing the actions appropriately.
The strategy is very simple: If the preceding candle opens and closes above the EMA10, and the current candle opens above but closes below the EMA10 and Stochastics(7,14,3) D value at the previous candle is >=70, then enter short limit at EMA10 of the previous candle and put a stop loss order at the high of previous candle +1 tick. For longs, do the opposite (D value <=30).
The code I use for these conditions is the following:
protected override void OnBarUpdate()
{
// Condition set 1
if (Open[1]>EMA(10)[1] && Close[1]>EMA(10)[1]
&& Open[0] * TickSize > EMA(10)[0]
&& Close[0] < EMA(10)[0]
&& Stochastics(7, 14, 3).D[1] >= 70)
{
EnterShortLimit(DefaultQuantity, EMA(10)[1], "");
EnterLongStop(DefaultQuantity, High[1] + 1 * TickSize, "");
}
// Condition set 2
if (Open [1]<EMA(10)[1] && Close[1]<EMA(10)[1]
&& Open[0] < EMA(10)[0]
&& Close[0] > EMA(10)[0]
&& Stochastics(7, 14, 3).D[1] <= 30)
{
EnterLongLimit(DefaultQuantity, EMA(10)[1], "");
ExitShortStop(Low[1] + 1 * TickSize, "", "");
}
}
For the backtesting:
- I use Market Replay speed 500x
- Fill type = liberal
- Slippage= 1
- Entries per direction = 1
On the following image you can see the entries that the strategy has missed but shouldn't:
I would appreciate if you could help me with this, Thanks in advance.
Comment