It works on any timeframe below daily.
I looked now at logic and can say that it is as follows:
- at 8:00 (checkhour) determine HH and LL for the current day (0:00-8:00);
- determine average range H-L for the last 7 days (days2check);
- open buy order at HH+avgrange/2 or sell order at LL-avgrange/2 (offsetK=2);
- profit is avgrange/2 (profitK=2), stop is avgrange/2 (lossK=2).
But it seems that there is one mistake in the code in closing orders and so far I'll be not fixing it, let's see how it goes (maybe this mistake made it profitable

).