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 habeebft, Today, 07:27 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Max238, Today, 01:28 AM
        4 responses
        38 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X