I have 2 orders, 1 long, one short, and wish to hold each for a different number of bars. I can't get the short trade to exit. Can you have a look?
else if (State == State.Configure)
{
AddDataSeries("ES 12-22", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (
ToTime(Time[0]) == FirstBarCloseTime
&& (Close[0] > Open[0]))
{
EnterLong(0, 1, @"nqLong");
EnterShort(1, 1, @"esShort");
}
// Set 2
if (BarsSinceEntryExecution(0, "", 0) >= BarsTofHoldNq)
{
ExitLong(@"nqLong");
}
// Set 3
if (BarsSinceEntryExecution(0, "", 0) >= BarsToHoldEs)
{
ExitShort(@"esShort");
}
}​

Comment