Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Removing Drawing Objects.

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

    Removing Drawing Objects.

    Hello,

    I have built an indicator which displays various market depth values at there respective levels, drawn with draw,text and each has its tag with a standard name + Currentbar and its Price level so all unique (e.g. BidSpread305971.20905). This works very well until there are a lot of them drawn it starts to slow down due to all the objects being held in memory I'm guessing, i would just like to remove these drawing objects after a certain number of bars. I have tried the RemoveDrawObject command using a string made up of the name + the CurrentBar less the number of bars to keep + i have tried regex, wildcards etc for any value after this to match the price component of the tag. I also tried to foreach loop through the texts in drawingobjects but cannot as it tells me object has been modified. So anyway, i was wondering if you would know of a simple way to limit the number of drawn objects of a certain type. Any advice much appreciated.

    Thanks

    Col

    #2
    Why not save the TagIds in a list?
    (Or dictionary, or queue ...)

    You will need the full TagId string in order to remove it.

    TagId = PrefixString + CurrentBar + PriceLevel <-- but why PriceLevel?

    If you'd stop appending that Price component, you'd probably have
    any easier time figuring out the older tags -- once you do, then just
    call RemoveDrawObject on the TagId.

    If you want to expire TagIds after X bars, then walk through your list,
    or dictionary, and any TagId with a CurrentBar component that is expired,
    you would remove it from the list/dictionary, and call RemoveDrawObject.

    A queue data structure would also work. Why? Because the head of
    the queue would always be the oldest TagId. Peeking at the head of
    the queue, you can tell if that TagId has expired -- if so, dequeue it
    and then call RemoveDrawObject.

    Comment


      #3
      thanks for your reply/help bltdavid, i have the price component in there because price will move during the formation of the bar and therefore the location of the indicated spread depth moves with the price so i had to add the price to make each drawing unique thus preventing the removal of prior drawings on same bar. Your idea sounds good though, I can just add each tag to a separate list for each bar and store those bar lists in a list, call element currentbar - n , cycle through that bar list passing each bar list element to RemoveDrawingObject.

      Thanks for the help and idea david, ill give it a run!

      Much appreciated

      Col.

      Comment


        #4
        Ah, I see.

        Many different tags on each bar, ah yes, now I see why Price
        is important to your TagId.

        Your coding idea sounds relatively straightforward.
        Have fun!

        Last edited by bltdavid; 05-13-2021, 07:58 AM.

        Comment


          #5
          Yep a List of Bar specific tag Lists, simple and efficient, works like a charm!

          Thanks again for the pointers David.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X