What is the strategy code that would send out an exit order to close a trade labeled "a" only if that trade is currently open, but would not even try to close out "a" if it is not open?
The strategy that I have now sends out the exit order for "a" whenever the conditions for the exit are met despite the fact that "a" was not even opened to begin with. This doesn't really cause any major problems since NT7 just ignores the exit order if it isn't applicable. But how would I prevent this attempted exit order execution from occurring in the first place?
What I've been using so far is:
if (Position.MarketPosition == MarketPosition.Long)
and this does prevent the exit order from trying to execute when I have no orders open. But this line of code doesn't help when I have order "b" open long, because this line of code just says to send the exit order when there is ANY position open long.
How do I limit it even further so that the condition is that -- only if "a" is long, then and only then send out the exit order: ExitLong("Exit a", "a") ?
Thank you very much.
Comment