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 armybender, 11-16-2023, 08:38 PM
      12 responses
      189 views
      1 like
      Last Post NinjaTrader_RyanS  
      Started by Ryan333, Yesterday, 05:25 PM
      4 responses
      16 views
      0 likes
      Last Post Ryan333
      by Ryan333
       
      Started by wuannetraam, Yesterday, 07:43 AM
      8 responses
      45 views
      0 likes
      Last Post wuannetraam  
      Started by ETFVoyageur, 05-18-2024, 12:45 AM
      11 responses
      59 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by grebow25, Today, 09:20 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X