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

Number of bars on chart

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

    Number of bars on chart

    Hi guys

    Two related questions here:

    1) BarsSinceSession will obviously get the number of bars since, say, the start of the day.

    But is there a simple (and maybe similar) method which will determine the number of (range) bars on a chart (not just the session)?

    2) One of the reasons for needing this is that I'd like the indicator I'm working on (whose purpose is purely to count) to only be effective for the latest bar, i.e. bar [0]. Is there a way of stipulating this?

    Any help as always greatly appreciated.

    #2
    arbuthnot, for identifying the last bar, you can use CurrentBar and Bars.Count :



    The barnumber OnBarUpdate() is processing



    The total number of bars / datapoints on the chart
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by arbuthnot View Post
      Hi guys

      Two related questions here:

      1) BarsSinceSession will obviously get the number of bars since, say, the start of the day.

      But is there a simple (and maybe similar) method which will determine the number of (range) bars on a chart (not just the session)?

      2) One of the reasons for needing this is that I'd like the indicator I'm working on (whose purpose is purely to count) to only be effective for the latest bar, i.e. bar [0]. Is there a way of stipulating this?

      Any help as always greatly appreciated.
      To calculate only on the current bar in real time, just use:

      Code:
       
      if (Historical) return;
      or
      Code:
      if (!Historical)
      {
      //process stuff here
      }
      Pick your poison.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      55 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      35 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      7 views
      0 likes
      Last Post cre8able  
      Working...
      X