I'm developing an indicator in NinjaTrader that uses a secondary tick series along with the primary time-based series. The indicator draws a rectangle on the chart using the OnRender() method. When the indicator is loaded, the rectangle is drawn correctly, but as the price updates, the rectangle disappears instead of moving dynamically with the price. This behavior only occurs when I add the tick series. Key Observations:
- Normal behavior without the tick series:
- If I remove the tick series, the OnRender() method works as expected: the rectangle is drawn and moves dynamically with price updates. This indicates that the rendering logic in OnRender() works correctly in a time-based series environment.
- Behavior with the tick series:
- When I add the tick series (AddDataSeries(BarsPeriodType.Tick, 1)), the rectangle initially appears but disappears as soon as the price changes. This suggests that adding the tick series interferes with the rendering cycle.
- Calculations in OnBarUpdate():
- The volume and price calculations for the tick series are handled in the OnBarUpdate() method under BarsInProgress == 1. No complex calculations or graphical updates are performed in OnBarUpdate(), beyond updating variables to handle buy and sell deltas.
- Not using InvalidateVisual() inside OnRender():
- I have avoided calling InvalidateVisual() inside OnRender() to prevent a redraw loop. However, I am still facing issues with dynamically rendering the rectangle when combined with the tick series.
It seems that the high frequency of updates from the tick series is interfering with the rendering cycle, causing the chart to stop rendering properly as the price updates in real-time. This may be due to NinjaTrader prioritizing tick updates over the rendering process or that constant data updates are interrupting the OnRender() cycle. Question:
How can I prevent the OnRender() cycle from being disrupted by the tick series? Is there any recommended approach to handle tick series while maintaining dynamic rendering without the graphics disappearing?
Find the code in the attachment.

Comment