Hi,
I try to calculate a simple Average Daily Range based on daily H - L to use in intraday context.
I used the TimeFrameSet method and manually checked if the result were as expected which they were not.
Using a more granular and manual approach, I calculated the same average with TimeFrameGetPrice to see what values were used. Still calculation was not what I expected.
I suspect it is due to daily H and L values that are used when transitioning from one day to the other.
To illustrate the issue, here are illustrations.
I use 1mn ES data which I set intraday to show "day session only" (although the database holds the 24 hours data).
Here are my DB settings:
First, here is the daily chart with current average H-L range for latest 2 days of 34. This is the level I expect to find on intraday data:
Now Here is my intraday Chart with a Value of 50.75 for latest day (the 27 latest data is possibly a reason of the problem, see below).
And here is the code.
Notice how value of dailyHigh, dailyHigh1..... change at 16.19.59.
I expected they would only change on next day: 16.19.59 is still same day as previous value, and I suspect that it is because of this that my end result is not what expected.
And indeed, altough dailyHigh value is what I expected it to use, dailyHigh1 is not the high of day based on daily, but high of last bar of previous day, which is not Daily high.
First question, is why is there a brief change of values for various variables on last day bar? Is there a way to prevent this?
Second question is, is this the reason why my calculation is not what is expected?