I also tried placing closing orders and closing positions within the OnStateChange event when State == State.Terminated, but what happens is that it closes the position but after executing and disabling the strategy, it opens positions in the opposite direction. For example, if I had 2 longs, they close, and 2 shorts are opened.
How can I achieve closing the open positions when disabling the strategy without opening other positions? Additionally, I would like to use the CLOSE button to close the strategy along with all positions and pending orders.
I also explored the options in the Tools - Options menu under the strategy section, enabling and disabling the close entries and close exits options, but it doesn't yield the desired result.
Please, if you could guide me on how to achieve what I need, I would greatly appreciate it. Thank you.
Comment