Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last 3 or 5 instances displayed

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

    Last 3 or 5 instances displayed

    Hiya,
    Using the Strategy Builder, I have made a simple indicator that draws a triangle up below the bar when the CCI is higher than the previous bar and vice versa, a triangle down above the bar when the CCI is falling.

    I know how, when assigning the Tag name in the string builder to assign String 0 to CURRENT BAR...that way, it prints arrows going back for ALL the data loaded I have in the chart.
    I also know how to leave String 0 as the indicator name, and then String 1 as "Triangle up_1"...this prints just the most recent occurrence, and then it disappears as soon as there is a new one.

    Using Current Bars makes the chart too messy, but using just one occurrence is not enough.

    How, using strategy builder, would I write it to show the last 3, or maybe 5 occurrences? Thanks in advance for the help.

    90

    #2
    HI 90bideven, thanks for posting.

    The builder does not have enough control over C# logic to keep an index like this. C# logic would be needed to control this e.g.

    Code:
    //class level
    private string[] arr = {"0","1","2","3","4"};
    private string str;
    private int count = 0;
    
    //in State.SetDefaults:
    str = "tag" + arr[0];
    
    protected override void OnBarUpdate()
    {
    if(Close[0]>Close[1])
    {
        Draw.Dot(this, str, false, 0, High[0]+TickSize*5, Brushes.Red);
        count++;
        if(count > 4)
        count = 0;
        str = "tag" + arr[count];
    }
    }

    Comment


      #3
      OK, thanks Chris...I will fiddle with that code and see if I can make it work. Thanks for the quick reply.
      90

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      596 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 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
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      554 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X