Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ezrollin, 02-26-2022, 11:14 PM
      7 responses
      206 views
      0 likes
      Last Post kenz987
      by kenz987
       
      Started by rocketman7, Today, 08:34 PM
      0 responses
      1 view
      0 likes
      Last Post rocketman7  
      Started by rt61968, 02-17-2018, 05:24 PM
      3 responses
      2,733 views
      0 likes
      Last Post MasterEtrad3  
      Started by nuobo, Today, 07:43 PM
      0 responses
      4 views
      0 likes
      Last Post nuobo
      by nuobo
       
      Started by ETFVoyageur, Today, 02:04 PM
      3 responses
      22 views
      0 likes
      Last Post ETFVoyageur  
      Working...
      X