Eugene,
Thank you for the advice. I switched to using ExitAt... with Position.AllPositions as you suggested.
However, I'm still puzzled by the logic to have both Stop and Profit Target alerts generated at the same time. It seems that if I have to peek from my 10 minute bars down to a lower time frame, then I might as well use that lower time frame data all throughout.
For example, I noticed when streaming for the day, a limit exit that was taken is not indicated on the chart until after the bar is complete. So in order to generate that limit exit before the bar is complete, I will need to peek at a lower time frame, such as the 1 minute bar. But even at this 1 minute scale, I will have to monitor the program every minute for a signal that will have been taken by the program up to a minute before it is recorded on the chart.
Also, there is an EOD data error thrown since bar+1 (used in the peeking) doesn't exist yet during real time streaming. I believe this is the cause of the error. if( bar < Bars.Count - 1 && target1 <= High[bar + 1] )
Is there some other logic that does not require peeking at a lower time frame so the Stop and Target alerts (for the respective split amounts of the position) are given at the same time, before the bar is drawn and the trade is hit? I researched how I could have AutoProfitLevel declared for the same bar exit, but this exits the full position not a split position.
Thank you again for your patience as I grow to understand the alert logic. Everything works as expected in backtest, it's just the live part that alludes me.
Happy holidays to you.
I refactored the code after seeing additional examples in the reference guides.
CODE:
Please log in to see this code.