What I am finding, though, is that one of the Exit calls (occassionally) doesn't appear to submit an order, and thus never gets executed to close the position.
For example, on one tick, we execute this code:
if ( doTrade )
{
EnterLong( 0, 10, "Long Primary" );
EnterShort( 1, 10, "Short Secondary" );
}
on a subsequent tick, we execute this code:
if ( exitTrade )
{
ExitLong( 0, 10, "Exit Primary", "Long Primary" );
ExitShort( 0, 10, "Exit Secondary", "Short Secondary" );
}
on subsequent ticks, I check the Positions[0 and 1] to make sure I've gone flat. But, one or the other the Exits will still be a full position (not even partially closed) after well more than 10 1-minute bars have gone by.
Is there a race condition or other problem that may occur when submitting orders on two instruments literally back-to-back? What can I do to guarantee that both orders are submitted and confirmed as received before continuing my strategy?
Thanks!

Comment