This code look great!
def bars = if GetDay() == GetLastDay() and SecondsFromTime(begin) >= 0 and
SecondsTillTime(till) > 0
then bars[1] + 1
else bars[1];
def todayvol = if GetDay() == GetLastDay() and
SecondsFromTime(begin) >= 0 and SecondsTillTime(till) > 0
then todayvol[1] + volume
else todayvol[1];
plot avgtime = todayvol / bars;
Would like to know how to understand the above code.
it seem pretty tough to understand for my side.
Would be quite glad if you could assist me on understanding the code.
It is just a way to count bars and accumulate volume.
Bars are counted only on the current (last) day between begin and till times within the seconds... code.
The reference of Bars[1] + 1 is a recursive function (referencing bars itself). It starts at the begin time with 1 and counts each bar and adds it to the previous Bars[1] count until the end time where Bars[1] holds the final count for the day.
Todayvol is doing the same as the Bars, but just accumulating volume instead.
Last edited by a moderator: