Announcement

Collapse
No announcement yet.

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());
        }
    }



    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X