I seem to be having problems with the OnStateChange() override when the state of my indicator goes to State.Terminated. I tested this outside my indicator in an indicator that has no other code in and I get the same results.
If my indicator is not on the chart and I add it through the indicators window, the method is called with the following states in this sequence:
- Terminated
- Configuring
- Terminated
This is obviously a problem as I cleanup any objects used in my indicator when the method is called with a state of Terminated.
The behavior when I remove my indicator from the chart through the indicator window seems OK, although it calls the method three times with a state of Terminated. I am guessing it is doing this because there are two other indicators on my chart and with mine it makes three.
Am I misunderstanding the flow of the OnStateChange() override completely? I attached two pictures, one with a code snippet that shows this behavior and one with the output I get when adding my indicator to a chart with my Print statements.
Thanks for any help.
Kind Regards,
John Steinberg
Comment