Forums › ProRealTime English forum › ProBuilder support › Determine the charts time frame in a program › Reply To: Determine the charts time frame in a program
04/19/2020 at 11:39 AM
#126864
This is as close as I can get after wasting far too much time on it. The issue we have is that as we get to faster time frames there isn’t always a candle where we would hope to find one so one day might have 288 candles in it and the next days 286 and then 270 and the same problem with counting how many candles in an hour. So the following works accurately on very liquid stocks on not very fast time frames only:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
if realbarsinday = 0 or realbarsinhour = 0 then count = count+1 hourcount = hourcount+1 if opendayofweek <> opendayofweek[1] then day1 = day2 day2 = day3 day3 = count count = 0 endif if openhour <> openhour[1] then hour1 = hour2 hour2 = hour3 hour3 = hourcount hourcount = 0 endif if day1 <> 0 and (day1+day2+day3)/3 = day3 and realbarsinday = 0 then realbarsinday = day3 endif if hour1 <> 0 and (hour1+hour2+hour3)/3 = hour3 and realbarsinhour = 0 then realbarsinhour = hour3 theoreticalbarsinday = realbarsinhour*24 endif endif return realbarsinday as "real bars in day", theoreticalbarsinday as" theoretical bars in day" |