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 argusthome, Yesterday, 10:06 AM
      0 responses
      20 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      18 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      38 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X