I have no idea why this error exists. In the case when the else section is commented out the scheme simply goes short at the open of the second bar which occurs at 9:40 AM (I'm using 5 minute bars). Then at 10:00 AM an order to reverse the position is given if the stop is hit. This is acceptable to NT.
However, when the else section is included, I get the above error message. In essense what I want is for for the "stop and reverse" order to cancel itself at 12:00PM and then for a "stop and exit" order to be submitted at 12:05 PM. I'm not clear at all why I can't do this. Any pointers would be appreciated.
protectedoverridevoid OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBar < 10)
return;
if (Bars.FirstBarOfSession)
{
EnterShort();
}
if (Position.MarketPosition == MarketPosition.Short)
{
if ( (ToTime(Time[0]) >= 100000) && (ToTime(Time[0]) <= 120000) )
{
EnterLongStop(20000.0);
}
/* elseif ( (ToTime(Time[0]) > 120000) )
{
ExitShortStop(20000.0);
}
*/
}
}

Comment