Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Counting Renko Bars in a session.

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

    Counting Renko Bars in a session.

    What is best way to count Renko bars in a session or multiple sessions?

    #2
    Hello GKonheiser,

    Thank you for your post.

    You will want to use something like this to get your session bars -
    if(Bars.FirstBarOfSession)
    int startBar = CurrentBar;

    Print((CurrentBar - startBar));

    There is also Bars.BarsSinceSession available as well.

    http://www.ninjatrader.com/support/h...ncesession.htm

    http://www.ninjatrader.com/support/h...rofsession.htm
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      is there no way of asking for the number of Renko bars in the last x sessions?

      Comment


        #4
        GKonheiser,

        You would want to use the Bars.FirstBarOfSession example that I provide and build your logic around that to track the different sessions and update your variables accordingly.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          GKonheiser,

          You would want to use the Bars.FirstBarOfSession example that I provide and build your logic around that to track the different sessions and update your variables accordingly.
          I’ve been very interested in this thread and thanks for your explanation, Cal.

          I’ve used ‘Bars.FirstBarOfSession’ quite a bit in my own coding, but there’s one thing I still don’t know how to do: and that is how to reference previous sessions (as per post #3) or just the previous session, etc.

          Could you please be so kind as to give a brief indication of what methods and/or code are used to achieve this.

          Thanks very much in advance.

          Comment


            #6
            Hello arbuthnot,

            Thank you for your post.

            You would need to manually track the count of bars in each in session. In the following example I use a list to store the value.
            Code:
            #region Using declarations
            using System;
            using System.ComponentModel;
            using System.Diagnostics;
            using System.Drawing;
            using System.Drawing.Drawing2D;
            using System.Xml.Serialization;
            [B]using System.Collections;[/B]
            using NinjaTrader.Cbi;
            using NinjaTrader.Data;
            using NinjaTrader.Gui.Chart;
            #endregion
            
            namespace NinjaTrader.Indicator
            {
                public class MyTestIndicator1 : Indicator
                {
                    #region Variables
                    private ArrayList sesBarCount = new ArrayList();
            		private int prevCount = 0;
                    #endregion
            		
                    protected override void Initialize()
                    {
                        
                    }
            		
                    protected override void OnBarUpdate()
                    {
            			if(Bars.FirstBarOfSession)
            			{
            				Print(prevCount);
            				sesBarCount.Add(CurrentBar - prevCount);
            				Print(Convert.ToInt32(sesBarCount[sesBarCount.Count -1]));
            				prevCount = CurrentBar;
            			}
                    }
                    #region Properties
                    
                    #endregion
                }

            Comment


              #7
              Thanks very much, Patrick. I would have had no idea how to do that.

              I've also learnt something about how to use lists, which has always been a bit of a mystery.

              Much obliged.

              Comment

              Latest Posts

              Collapse

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