Irvine, CA
Experience: Intermediate
Platform: Ninjatrader
Trading: Piano, ES, GC, CL, NQ, 6E
Posts: 21 since Feb 2011
Thanks Given: 5
Thanks Received: 4
|
Hello guys,
I have what’s naturally an unsupported question for ninjatrader but would like to see if I can get some input from you guys. I have a strategy that has a custom button on it and this custom button when clicked adds an indicator to the chart. I was able to achieve this by using the following code in OnStartUp() in the strategy.
Indicatorbase indicatorTemplate = new ADX(13);
indicatorTemplate.Panel = 1;
Then in the event Handler for by button click I do something like this.
ChartControl.Add(indicatorTemplate);
This part works fine and it adds the indicator to the chart in panel 1.
The problem I run into is when I want to remove the indicator from the chart.
If I call
ChartControl.Remove(indicatorTemplate);
Nothing happens. If I click the button again then it adds another copy of ADX(13) to the 1st panel. If I close the chart nothing happens. If I reload Ninjascript it throws this nasty NT7 error saying I broke everything.
It seems it should work. The only thing I can see that is different between Add and Remove is the following
Add give this in intellisense (IndicatorBase indicatorTemplate)
While Remove gives this (IndicatorBase indicator)
Any help would be much appreciated.
|