When I draw the new line, the previous one disappears, and I would like to be able to make it persist. But I haven't found a way to do that. Is there a simple way to do this? Or can you point me in a direction to investigate?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Tag for persistent RenderTarget DrawLine
Collapse
X
-
Tag for persistent RenderTarget DrawLine
How do I make a line persistent when drawn with RenderTarget.DrawLine? My usecase: I add data series via script, calculate SMA value, and use RenderTarget.DrawLine for the SMA value. When I get a new Bars[1], I draw a new line. This part is working fine.
When I draw the new line, the previous one disappears, and I would like to be able to make it persist. But I haven't found a way to do that. Is there a simple way to do this? Or can you point me in a direction to investigate? -
Hello jculp,
Thanks for your post.
Something you could do is create a list of what you want to have drawn, and to add items to the list in OBU.
The List could contain a class that contains barIndex and price value. Then in OnRender, loop through ChartBars.FromIndex and ChartBars.ToIndex, then loop through your list to see if the barIndex is in that range, if the bar index is in that range, call RenderTarget.DrawLine within your loop. This will cause multiple lines to be drawn.
Note that ChartControl.GetXByBarIndex and ChartScale.GetYByValue can be used to convert barIndexes and prices to X and Y coordinates.
See the help guide documentation below for more information.
ChartBars.FromIndex: https://ninjatrader.com/support/help..._fromindex.htm
ChartBars.ToIndex: https://ninjatrader.com/support/help...rs_toindex.htm
ChartControl.GetXByBarIndex: https://ninjatrader.com/support/help...bybarindex.htm
ChartScale.GetYByValue: https://ninjatrader.com/support/help...etybyvalue.htm
Let us know if we may assist further.
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
628 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
359 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
562 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment