Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Removing Text painted by indicator

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

    Removing Text painted by indicator

    Hi there,

    Is it possible to remove text painted on to a chart which was added by an indicator? The text to be removed would be on a previous days chart, say all days after 2 days ago.

    For example, this code added a number below a candlestick on a chart...

    Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar, _tmpBrush, myFont, TextAlignment.Center, null, null, 1);


    The problem is, over time there would be too many text elements added to the chart, so it would be good to be able to delete text from previous days.

    Thank you!




    #2
    Hello globaljobber,

    If you use the CurrentBar as the Tag you could use a for loop to remove objects pretty easily.

    This would be pretty resource demanding so you would likely want to only do this once at the start of the new session.
    Code:
    if (Bars.IsFirstBarOfSession)
    {
        int startBar = CurrentBar - 1; 
    
        for(int i = startBar; i > 0; i--)
        {
            RemoveDrawObject(i.ToString());
        }
    }



    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.

      Would the RemoveDrawObject command remove ALL objects from ALL indicators on the chart, or just the objects associated with the actual indicator within which the RemoveDrawObject command was called?

      Thanks!

      Comment


        #4
        Hello globaljobber,

        That would relate to the objects that script has drawn.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rdtdale, Today, 01:02 PM
        0 responses
        1 view
        0 likes
        Last Post rdtdale
        by rdtdale
         
        Started by alifarahani, Today, 09:40 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by RookieTrader, Today, 09:37 AM
        4 responses
        18 views
        0 likes
        Last Post RookieTrader  
        Started by PaulMohn, Today, 12:36 PM
        0 responses
        7 views
        0 likes
        Last Post PaulMohn  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        41 views
        0 likes
        Last Post love2code2trade  
        Working...
        X