Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tag for persistent RenderTarget DrawLine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X