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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      666 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      377 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      110 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X