The NinjaTrader Docs ( at https://ninjatrader.com/support/help...getchanged.htm ) suggest using `OnRenderTargetChanged` to handle the creation/disposal of `dx` objects (for example, i talk about brushes). However, it's obviously, that according to the docs, we have to code the disposal handling code in two places (inside OnStateChange and OnRenderTargetChanged).
Which makes our work complicated (everytime we create a brush or variable, we have to add handling code for their disposal in two areas)
So, my suggestion
It would be nice, that like "State" property of NinjaScript, there was State property for RenderTargetState. So, we could easily make such code:
public override void OnRenderTargetChange() { if (RenderTartgetState == RenderTargetState.Initialize) // the first trigger of RenderTarget, probably like when "DataLoaded" happens only once { myDx= brush.ToDxBrush(RenderTarget); .... etc } else if (RenderTartgetState == RenderTargetState.Default) // the default state when happens on each event, like clicking on chart or etc.. { myDx= brush.ToDxBrush(RenderTarget); .... etc } else if (RenderTartgetState == RenderTargetState.Dismissed) // the only last state when chart/indicator is removed, this should trigger only once, like State.Terminate happens { if( myDx != null) { myDx.Dispose() ... etc } } }
So, this feature will simplify our work with RenderTarget. no need to hook something in "OnStateChange" any longer.
I also see, that this update wont conflict anything with existing. Just create a new property named "RenderTargetState" and assign the value to it, and then we will do the rest. No drawbacks i see.
Comment