Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RemoveDrawObject not working in real time

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

    RemoveDrawObject not working in real time

    Hi. When I use the RemoveDrawObject function to remove a specific drawing (the tag value is definitely unique -- it's generated using the current bar value plus a static text string), it doesn't work in real time (i.e., if I refresh the indicator the drawings that should have been deleted do disappear).

    The indicator updates on every tick. The drawings are placed on the chart if a certain set of conditions are met, and once drawn on the chart a flag is set to true to note that the drawing exists. A separate variable continues to track whether or not the conditions still apply with each incoming tick.

    On the first tick of the next bar (before the condition flag and drawing existence flags are reset for the new bar), there is a check of the condition flag and the drawing existence flag. If the conditions were not met on the last tick of the previous bar and the flag for the existence of a drawing is true, then the RemoveDrawObject() function is called for that specific tag ID (e.g., RemoveDrawObject("entryTag")). I added a Print to confirm that I'm reaching the conditional code block which contains the remove function.

    Is there something obvious that I might be doing wrong, or are you aware of any bugs with this function? Again, when I refresh the indicator, objects are correctly removed.

    Thank you.


    Regards,

    #2
    This method is behaving as expected. I can't see at first glance what you may be doing wrong but there must be a logic flaw somewhere.

    See my test indicator that demonstrates functionality in real-time. Run it on a 10 second chart to see. Import via File > Utilities > Import.
    Attached Files
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for the example, Ray. I figured out my mistake.


      Regards,

      Comment


        #4
        Hallo Patrick,

        I have a problem with the drawobject horizontalLine:

        in this code i sometimes get very strange results for EndY or StartY: i.e. for the YM (Dow Jones Index Future)


        StartY: 16418,1657387173 ok
        StartY: 0,884842374170404 ?
        StartY: 1,6402270361435] ?
        the last two values are completely worng because YM has now 16479 points.
        for EndY the results sometimtes very strange too

        the chart is really empty, no indicators , and lines completely cleared before drawing horizontal lines.

        private void storeLines()
        {


        MyLineStore.removeTfDict(Instrument.MasterInstrume nt.Name,BarsPeriod.Value);
        foreach (IDrawObject draw in DrawObjects)
        {
        if (draw.UserDrawn && draw.DrawType == DrawType.HorizontalLine)
        {
        ILine globalLine = (ILine) draw;
        if(globalLine.Pen.Color != Color.PaleTurquoise) continue;
        string lineTag = globalLine.Tag;
        MyLineStore.AddHLine(Instrument.MasterInstrument.N ame,BarsPeriod.Value,lineTag,globalLine.StartY);
        }
        }
        }

        Thank You

        Rolf Theus

        Comment


          #5
          Hello RolfTheus,

          Thanks for your post.

          To understand this correctly, you are going through the manually drawn objects on a chart and attempting to create new lines at the same y axis level, is this correct?

          The issue that you are having is that the StartY for the drawing object you have created is not showing the price at which it was drawn, is this also correct?

          Inside of your loop I would like you to print the following:
          Print(globalLine.StartY)

          Does this print show the correct StartY level of the manually drawn line?
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          666 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          376 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          110 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          580 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X