How to test if we are on the latest bar ?

Forums ProRealTime English forum ProBuilder support How to test if we are on the latest bar ?

Viewing 4 posts - 1 through 4 (of 4 total)
  • #113316

    Hi,

    I am writing an indicator where sometimes I want to calculate against all bars, and sometimes only against the most recent bar.

    Effectively I want to be able to use “DEFPARAM CalculateOnLastBarOnly” but within an IF statement driven by a boolean variable declared against the indicator ( thereby allowing a user to control the output ).

    However, from what I can see the DEFPARAM can’t be placed within an IF, and so I need to code this for myself.

     

    How do I detect ( elegantly !! ), if I am currently working against the “current” candle ?

    This indicator can be used against ANY timeframe, and so comparisons against currenttime become quite messy, quite quickly.

    BarIndex effectively numbers from the beginning of the available bars – I need the inverse of BarIndex, so that I’m at 0 when on the current bar.

     

    Does anyone have any elegant solutions ?

     

    Regards,

     

    Bob

    #113317

    With the use of the new available instruction (only in version 11) : IsLastBarUpdate

     

     

    #113318

    Hi Nicolas,

     

    Thanks for the quick reply – it’s good to know there is now a built in way of achieving this ( is full documentation of the new v11 commands available as yet ? ).

     

    However, my users are mainly customers of IG, who have not rolled out v11 yet, and so I still need to achieve this the “old fashioned” way .. 🙁

     

    If anyone has any good ideas, I’d be very grateful.

     

    Regards,

    Bob

    #113400

    The old way was by using this kind of condition:

     

     

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

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