Is there a way to check whether certain entry orders are still active in a strategy?
I have my strategy set to enter with five different orders, named "Entry01" to "Entry05". They all have their own profit targets. I also have a variable that is incremented based on an Indicator plot which is acting as my Trailing Stop.
When price crosses the Trailing Stop value, I want it to exit all but one of the remaining open positions. I know how to exit everything, and I know how to close individual entry orders, but the Trailing Stop doesn't even become active until after the Indicator variable has gone past my entry point, by which time at least one or two of my profit targets have already been hit. I won't know how many of the TPs have been hit, though, so I need to individually close only some of the original orders.
Rather than sending an individual exit order for all entries, thereby forcing an error on those that have already hit their targets, I want to check for the presence of the remaining orders and only send the relevant exit orders. I figure it would look something like this:
if(ExistsIn.Account.Positions("Entry03")
{
ExitShort("Entry03");
}
I have seen where some people use a foreach loop to cycle through the active positions, but then how do I compare the name of each position to the list of possible still actives, and only close up to "Entry04"?
Thanks in advance!

Comment