If anyone can help me that would be much appreciated as I have been pulling my hair out for 24 hours over the seemingly complete randomness of this issue!
So I have added buttons to the toolbar modelling the following code
First I was using the Dispose() method to clean up my resources (remove my added buttons) and this created so many problems. All the problems went away when I changed over Dispose() for OnTermination() and everything has been working almost perfectly since then.
There is one strange and persistant issue though and that is when a workspace is closed, some of the charts that are runnig the indicator with buttons on it dont seem to be running the OnTermination therefor not deleting the buttons on these randomly selected charts. So when i open the workspace again there is two sets of buttons on some charts, one set works and one doesnt. Really frustrating as is seems as though Ninjatrader is randomly selecting which charts to skip OnTermination on as it is not always the same chart/charts with the problem.
The worst this is, as you can see from the code below, the print method makes it really easy to see when the OnTermination is run except Ninjatrader cloeses the Output window when you close a workspace making it impossible to track whats going on!
protected override void OnTermination()
{
if (buttonsloaded==true)
{
strip.Items.Remove(btnZZ1);
strip.Items.Remove(btnZZ2);
strip.Items.Remove(btnZZ3);
Print("Ran Termination");
}
Can anyone understand whats happening here?
Comment