In my main code (onbarupdate), I create my long and short orders by using this code:
entryShortOrder1 = EnterShort(numcontracts, "target1short");
entryLongOrder1 = EnterLong(numcontracts, "target1long");
My question is, is my logic and syntax correct?
private void StopStrategy()
{
if (entryLongOrder1 != null){
CancelOrder(entryLongOrder1);
}
if (entryShortOrder1 != null){
CancelOrder(entryShortOrder1);
}
// If we have a position we will need to close the position
if (Position.MarketPosition == MarketPosition.Long)
{
entryLongOrder1 = ExitLong("target1long");
}
if (Position.MarketPosition == MarketPosition.Short)
{
entryShortOrder1 = ExitShort("target1short");
}
haltProcessing = true;
}//end stopstrategy
Comment