There appear to be a number of possible contexts in which Initialize() can be invoked, including:
- When adding a strategy in the Strategies tab of the Control Center
- When adding a strategy on a chart
- When starting a strategy
I know that one can check if a strategy has been started on a chart by checking if this.ChartControl is not null, indicating the strategy is active and was started on a chart.
If one adds a strategy in the Strategies tab of the Control Center (not on a chart) and starts it, even though the strategy is active, this.ChartControl is (quite correctly) null and so cannot indicate if the invocation of Initialize() came as the result of starting a strategy or some other non-start context.
The challenge is to determine when Initialize() has been invoked and in what context for all possible contexts and to be able to know the current status of a strategy.
For example, using just this.ChartControl, one cannot distinguish between invocation of Initialize() when a strategy has not been started and when a strategy not on a chart has been started.
This is significant when adding data series because OnStartUp() is not invoked until all data series are added, even though Initialize(), from where the series were Add'ed, will exit before all data series are added. So one cannot use OnStartUp() to determine if the strategy has been started or if Initialize() has been invoked in a non-start context.
I would be most grateful for a way, albeit unsupported, to reliably know the invocation context and status of Initialize() and the current status of the strategy.
Thanks!
Comment