Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

# of Renko or Range bars per time interval

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

    # of Renko or Range bars per time interval

    Hi guys

    Would there be a way of counting the number of Renko (or Range) bars per n minute interval?

    I'm guessing this would need to be achieved on a Renko + time-based chart.

    (With this, I'll try to construct as part of strategy something in the line of a moving Renko bar counter. This could be a nice way to try to detect price consolidation.)

    Any help with this will be much appreciated.

    #2
    Originally posted by arbuthnot View Post
    Hi guys

    Would there be a way of counting the number of Renko (or Range) bars per n minute interval?

    I'm guessing this would need to be achieved on a Renko + time-based chart.

    (With this, I'll try to construct as part of strategy something in the line of a moving Renko bar counter. This could be a nice way to try to detect price consolidation.)

    Any help with this will be much appreciated.
    Code:
    double elapsedMinutes = 5; //make this a parameter?
       int barsElapsed = GetBar(Time[0].AddMinutes(-elapsedMinutes));
       
       //see what happens by showing stuff in the output window
       
       Print(null);
       Print(String.Format("Start Bar for measured period: {0}", CurrentBar - barsElapsed));
       Print(String.Format("Bar {0}: Bars elapsed in {1} minutes: {2} ", 
            CurrentBar, elapsedMinutes, barsElapsed));
    Unfortunately, I now realize that GetBar is not documented. What is documented is Bars.GetBar, which actully works opposite the way that GetBar works!

    You would have to turn the code around if you prefer to use Bars.GetBar. (see the documentation). IOW, Bars.GetBar will return the bar index; GetBar returns the bars ago that the time indexes.

    Be advised accordingly.

    Comment


      #3
      I'm really grateful to you, koganam, for this advice, as many times before.

      Once I've fully mastered this, then I'll really start thinking I'm making serious progress with NinjaScript.

      Much obliged.

      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
      573 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      575 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X