Apprentice wrote:You can't count real number of bar on H1 in a range of a year.
Historical data has a limited side, so you just will not have enough data.
On a small ranges you can have something like this:
local a = core.now();--Today's date
local b = a - 365;--Date one year ago,year value
local a_index = core.findDate(source, a, false);
local b_index = core.findDate(source, b, false);
if b_index < 0 or a_index < 0 then
--not enought data
else
local distance_bars = a_index - b_index;
end
The only thing you can do on the long distances is to approximate.
local range = source:date(NOW) - source:date(0);
local rate = range / source:size();
local distance_bars = (a - b) / rate;
Thank you for your answer. Let me test it.