bobtParticipant
Average
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
With the use of the new available instruction (only in version 11) : IsLastBarUpdate
bobtParticipant
Average
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
The old way was by using this kind of condition:
IsLastBarOnChart=currenttime=opentime and date=today