The strategy is a simple crossover on an indicator I use but I want to execute the trade when Close[0] i.e closing price on my 4 min chart crosses above/below the indicator (ATRTrailingStop of the 4 min char) but also when Close[0] is > ATRTrailingStop of the 4 hour chart.
Here is what I have in the code
declarations
private ATRTrailingStop ATRTrailingStop1;
private ATRTrailingStop ATRTrailingStop2;
in State == State.Configure
AddDataSeries(Data.BarsPeriodType.Minute, 4);
AddDataSeries(Data.BarsPeriodType.Minute, 240);
in State == State.DataLoaded
ATRTrailingStop1 = ATRTrailingStop(Close, 10, 3.03);
ATRTrailingStop2 = ATRTrailingStop(Closes[2], 10, 3.03);
in OnBarUpdate()
if ((CrossAbove(Close, ATRTrailingStop1, 1))
&& (Times[0][0].TimeOfDay > new TimeSpan(6, 30, 0))
&& (Times[0][0].TimeOfDay < new TimeSpan(13, 40, 0))
&& Close[0] > ATRTrailingStop2[0])
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if ((CrossBelow(Close, ATRTrailingStop1, 1))
&& (Times[0][0].TimeOfDay > new TimeSpan(6, 30, 0))
&& (Times[0][0].TimeOfDay < new TimeSpan(13, 40, 0))
&& Close[0] < ATRTrailingStop2[0])
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
What am I missing here?
Comment