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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Renejm, Today, 06:17 AM
        0 responses
        2 views
        0 likes
        Last Post Renejm
        by Renejm
         
        Started by kazisl, Yesterday, 06:41 PM
        2 responses
        9 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by tsdfyu, Today, 06:12 AM
        0 responses
        3 views
        0 likes
        Last Post tsdfyu
        by tsdfyu
         
        Started by impactX, 05-04-2021, 01:07 AM
        1 response
        6 views
        0 likes
        Last Post Lancer
        by Lancer
         
        Started by op1031, Yesterday, 05:51 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X