Last bar on chart ? intra bar or closed ?
Forums › ProRealTime English forum › ProBuilder support › Last bar on chart ? intra bar or closed ?
- This topic has 9 replies, 5 voices, and was last updated 5 years ago by Nicolas.
-
-
09/08/2016 at 9:00 PM #12874Last bar on chart ?
How to execute section of indicator code when at last bar on chart and not on previous bars ? ( Other sections of indicator code may well execute on every bar )Intra bar or closed ?
How to know …. Is last bar on chart mid way through formation or closed ?09/09/2016 at 8:17 AM #12878About last bar on chart, since we can’t know if the current barindex is the last one, you can make use of Time and CurrentTime and compare their values.
For your second question, if the bar is closed, that’s already happened and you are already in the next intra bar. So every Close[0] you can test, in real time are intra bar as long as it is not closed. You can also make use of time comparison to know you are still in the current bar.
09/09/2016 at 10:13 AM #12881Thank you Nicolas for replying and so quickly.
Not sure how Time and CurrentTime might work for static charts, instruments not trading over weekend, etc
Perhaps you could show us by writing a LastBarOnChart function that worked for most data & timeframe & tick chart scenarios.
Perhaps you could also have a go at an IntraBar function that when called returned something like …
1 – Opening tick of bar
2 – Closing tick of bar
3 – IntraBar tickI would personally find these very useful for coding in PRC and use them often as i’m sure others would.
Many many thanks in advance
Mark 🙂09/09/2016 at 1:09 PM #12885Something like this would work to get the last bar on chart:
123LastBarOnChart = date=today and currenttime<time+1 and currenttime<>timereturn LastBarOnChartAbout the other things, could you provide us more explanation and how you’d like to use it?
1 user thanked author for this post.
09/09/2016 at 4:54 PM #12905Brilliant Nicolas LastBarOnChart function appears to work really well, thank you, great work !
Some scenario’s Bar Status function might be useful for …
1. count how many times intrabar a particular price level is touched
OR
2. a user monitoring charts might employ a text alert for when a new bar starts or current bar closes
OR
3. indicator is based on Open values and only needs to calculate on 1st tick of a new bar
OR
4. capturing indicator extremes ( OB/OS ) intrabar12/28/2017 at 7:58 PM #56761Another solution to get the last barindex can be found in this topic: How to know EOF? the last barindex?
07/20/2019 at 7:41 PM #103028Depending on what time zone the instrument is trading at, you probably have to adjust to:
(70000 is 7 hour difference between Paris Timezone and Chicago Timezone)
123LastBarOnChart = date=today and currenttime+70000<time+1 and currenttime+70000<>timereturn LastBarOnChart1 user thanked author for this post.
10/02/2019 at 7:51 PM #109130Hello Nicolas,
I have the impression that the code snippet that you proposed for the LastBarOnChart does not work anymore in prorealtime V11. Do you have another suggestion
that I can try to identity the last bar on the chart in V11?Thanks!
1 user thanked author for this post.
11/05/2019 at 6:21 AM #112149Hello Nicolas,
As stated by John Doe, this code doesn’t work anymore on PRT v11. «TODAY» and «DATE» return exactly the same information on each bar. Same with «TIME» and «CURRENTTIME».
Also «CURRENTDAY» is really missing… How difficult would it be to add it in a next minor version?
My usage: you’ve created some fractal indicators, which work great. But on the last bars, nothing is detected, because we have a lookback of N bars. Hence, with a lookback of 10 bars, at day 100, I can only detect a pike at day 90. If I could count the number of bars between a specific bar and today, that would help reducing the lookback progressively. And detect latest pikes!
In fact, it’s not CURRENTDAY that would help, but DAYS and a new CURRENTDAYS. This way we can compute how much bars from TODAY we have.
Thanks!
11/05/2019 at 10:02 AM #112161You are right, TODAY was a great workaround to reduce the calculation and your example is perfect.
However, I had confirmation that a new instruction should be available this week or the next one (in version 11) that replace what we used to do with TODAY. This new keyword will return a boolean value each time the last bar on chart is updated.
-
AuthorPosts
Find exclusive trading pro-tools on