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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      65 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Working...
      X