Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to check if a drawobject exists?

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

    How to check if a drawobject exists?

    Try to get rid of some repeating drawobjects. Is there a ninjascript or c# function like this:
    boolean ExistsDrawObject(TagID).

    Thanks in advance.

    #2
    I don't know if such does exist but I'd be surprised if it doesn't exist.

    That said, I've written a couple of "target" drawing indicators where I want to know....say the mid point of the last swing or the 100% extension of the prior upswing after a retracement.

    In those cases I also want to know a couple or a few of the prior "targets" but I also do not want to have targets painted all the way back to the beginning of the chart.

    So, the solution I use is a simple toggle.

    int toggle = 0;

    toggle++; // on each instance of wanting to draw something

    DrawDot("Tag" + (toggle % 3), 0, CCI(14)[0], Color.Red);

    toggle % 3 means divide toggle by 3 and give me the remainder ( modulus math function ). So the numeric value being appended to "Tag" is always going to be 0,1 or 2 and as those cycle so to does the dot on the screen since C# will just remove the last instance of Tag0 and draw a new Tag0 at the new location.

    It's an approach that reduces management but isn't right for all situations. Where I've used it I've set the divisor ( 3 in the example ) as a parameter I can adjust because at smaller time frames I may not want any targets but at larger ones I may want 4 or 5.

    No idea if it is right for what you are doing, just tossing it out as an idea.

    Comment


      #3
      Newshues, thanks for sharing your idea. I'll use a variable to store the Currentbar of the Drawobject. A new Drawobject will be drawn only if my rules are passed && (new Currentbar - stored Currentbar) > 2. This will get rid of the 3 consecutive drawobjects in a row situation.

      Comment


        #4
        Thanks for the ideas guys, there is no collection of draw object tag Id's.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 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
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X