I have a timer I built into a strategy to draw different items on the chart it is attached to. I would like to try to save some computer resources by filtering when the draw actions actually occur by limiting it to only when the chart is active or in the forefront. Which way would be better, the best I could I figure out is below.
Also, I wanted to know which method to use to bring a chart that is in the background or a chart that is open as a tab but not the active tab, and bring it to the forefront?
public bool ChartActive() { if(ChartControl != null) { NinjaTrader.Gui.Chart.Chart chart = Window.GetWindow(this.ChartControl) as NinjaTrader.Gui.Chart.Chart; if(chart.Focus()) { //Draw stuff } if(chart.IsActive()) { //Draw stuff } return true; } else return false; }
Comment