How to count the number of bars on charts
Forums › ProRealTime English forum › ProBuilder support › How to count the number of bars on charts
- This topic has 8 replies, 2 voices, and was last updated 6 years ago by OlivierLarue.
-
-
12/25/2017 at 12:36 PM #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
12/25/2017 at 8:46 PM #56534Barindex 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.
12/26/2017 at 12:22 PM #56549Thank 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”…
My code1234567// 45 units = 544 bars on chartindex = 544 - barIndexDRAWTEXT("#index#", barindex, High, Dialog, Bold, 12)RETURN12/26/2017 at 1:43 PM #5655412/26/2017 at 6:05 PM #56576Yes, 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…
12/27/2017 at 9:10 AM #56608Until 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.
12/27/2017 at 10:55 AM #56628OK, 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…
12theDay = 42score = CALL "myCustomFunction"[param1, param2](Close[theDay])12/27/2017 at 11:30 AM #56631Still 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:
1234567defparam drawonlastbaronly=truefor i = 0 to intradaybarindex dodrawtext("#i#",barindex[i],high[i])nextreturn2 users thanked author for this post.
12/27/2017 at 12:10 PM #56634Thank you very much Nicolas, that does exactly what I looking for.
-
AuthorPosts
Find exclusive trading pro-tools on