Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set a yesterday and today only condition for indicator signals

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

    How to set a yesterday and today only condition for indicator signals

    i've run into a situation where signals from an indicator bog down performance and i'ld like to add a "number of days" i.e. 2 to the signal portion of the indicator.

    i tried using RemoveDrawObject( @"HEsignalUp" + (CurrentBar - SignalsToKeep) ); where SignalsToKeep is set to 500
    but this causes major problems. It works ok for a chart with 5 days but at 35 days the program hangs up displaying the chart even though the output window shows that the calculations for the indicator data has finished.

    i'm hoping to add a condition that won't let the signal portion run until the chart reaches yesterday's data if that's possible...

    thanks,
    w

    maybe it'll just be easier to plot the signals as a plot instead of a drawobject...
    Last edited by stafe; 03-08-2021, 09:17 PM.

    #2
    Hello stafe,
    You need below code:
    Code:
    for (int i = 0; i < CurrentBar - 500; i++)[INDENT]{
    RemoveDrawObject("HEsignalUp" + i);
    RemoveDrawObject("HEsignalDown" + i);
    }[/INDENT]
    Hope it helps!

    Comment


      #3
      thanks s.kinra, i'll give that a whirl and see if it's any better on a 35 day chart than my less than klunker method.
      i've seen lots of your posts and wanted to extend thanks for helping folks out.
      i'm not much of a programmer but i've got these big ideas sometimes and i get in over my head.
      i wound up creating plots for the signals and that method doesn't bog down the charts with object refreshes or whatever it's doing when there are 25,000 draw objects on the chart

      Comment


        #4
        Hello stafe,

        Thanks for your post.

        Yes, plots would be a better use of resources if possible to use.

        Another way you might handle draw objects is to limit their creation to say 100 (or whatever number you want to limit to).

        You could create a draw object counter that you add to the tag name.

        When the counter reaches 100, you would reset it back to 0.

        What happens is that when a new object is drawn, it will automatically remove the previously drawn object (100 objects ago) which takes care of that for you.

        Example:

        if (conditions to draw an object)
        {
        myDrawCounter++; // increment draw counter

        Draw.Dot(this, "myDot"+myDrawcounter, 0....);
        }

        if (myDrawCounter == 100)
        {
        myDrawCounter == 0; // reset for next 100 objects
        }

        This way you only ever see 100 of the latest drawn objects.

        Comment


          #5
          thanks for getting back PaulH. that was something i forgot happens - when you make another draw object with the same tag id the previous one is erased.... good method using the nature of object tags

          i found the section on manipulating date and time objects so i'll look into that further also to satisfy the curiosity about triggering indicator events...

          thx,
          wes
          Last edited by stafe; 03-09-2021, 07:06 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          599 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          344 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          558 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          557 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X