How to count the number of bars on charts

Forums ProRealTime English forum ProBuilder support How to count the number of bars on charts

Viewing 9 posts - 1 through 9 (of 9 total)
  • #56524

    I would like to find out how many bars are loaded on the chart.

    What I’m trying to achieve is to have an indicator showing the current barIndex from 0, incrementing by 1 onto the last bar.

    But I want the index on the right starting from 0…

    How to achieve that ?

    Thank you

    #56534

    Barindex instruction is what you need to achieve what you want to. I can’t answer with more precision to your specific code query now, but you can try to get more examples by searching for this keyword on forums.

    1 user thanked author for this post.
    #56549

    Thank you very much for your reply Nicolas (and everything you have been doing on this site), I did some researches before starting this topic and found barIndex.

    But where I’m having difficulties is to count “backwards”, from right hand-side zero/0, to left hand-side ${numberOfBars} (eg. 544).

    I could do that easily if I could find a way to store the numbers of bars loaded on my indicator but I didn’t find anything about that…

    Here is an example of my indicator, with my ${numberOfBars} variable beeing “hardcoded”…

     

    #56554

    Sorry but I do not understand well, since barindex is actually the bars quantity displayed on the chart. So admitting you want to know the bar number from now, 10 bars ago, just subtract 10 from barindex.

    #56576

    Yes, but I only know the maximum number from the last bar on the right.

    Would you know how I could “know” the maximum bar index from another bar on the left ?

    What I’m trying to do is to display the bar index in reverse order like on this screenshot…

    #56608

    Until the data history is fully loaded, you can’t know how many bars that will be loaded at the end. If you could explain me what is your full project, I could help way better 🙂

    1 user thanked author for this post.
    #56628

    OK, thank you Nicolas.

    I’m just getting started on ProRealTime, and trying to find ways to debug what I’m doing.

    I just wanted to display on the bars the current close index number from the current day.

    So that when I call a custom indicator function from a screener, I can check quickly that the day I requested matches what I asked for.

    For example, if I call the following snippet, I can check easily which bar is the number 42 from today, instead of counting down the days myself…

    It makes it faster to debug…

    #56631

    Still not sure to understand well sorry, but this snippet will plot on the price chart the candlestick number count from the current one, from right to left:

     

    2 users thanked author for this post.
    #56634

    Thank you very much Nicolas, that does exactly what I looking for.

Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login