Last bar on chart ? intra bar or closed ?

Forums ProRealTime English forum ProBuilder support Last bar on chart ? intra bar or closed ?

Viewing 10 posts - 1 through 10 (of 10 total)
  • #12874
    Last 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 ?
    #12878

    About 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.

     

    #12881

    Thank 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 tick

    I 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 🙂

    #12885

    Something like this would work to get the last bar on chart:

    About the other things, could you provide us more explanation and how you’d like to use it?

     

    1 user thanked author for this post.
    #12905

    Brilliant 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 ) intrabar

    #56761

    Another solution to get the last barindex can be found in this topic: How to know EOF? the last barindex?

    #103028

    Depending 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)

    1 user thanked author for this post.
    #109130

    Hello 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.
    #112149

    Hello 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!

    #112161

    You 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.

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

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