PureBytes Links
Trading Reference Links
|
Greg:
>But I am looking for code for average range (not true range) of several
>(10) days using intraday data.
That was my point. What I suggested will give you a close
approximation to what you want. In my opinion, it's better because
it takes into account far more data (using a 24-hour sliding window)
which would result in a smoother average.
>I think you have supplied average range of bars included in one day of
>intraday data.
No, what I supplied is a calculation of the highest high and lowest
in the past 24 hours, and the result is the average of that result
over the last N days. I'll say it again, with more comments:
{bars_per_day is the number of intraday bars in a day}
{dailyrange is the high-low range over the past 24 hours}
dailyrange = Highest(H, bars_per_day) - Lowest(L, bars_per_day);
{avg range is the average daily rainges over the past 'days' days.}
avg_range = XAverage(dailyrange, days*bars_per_day);
If you don't want the sliding window, then you need to maintain a
circular array that updates the day's high-low range on each daily
close, and then average that.
-Alex
|