Announcement

Collapse
No announcement yet.

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

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