PureBytes Links
Trading Reference Links
|
Ian,
>I am trying to apply the formula you give above to calculate a 10 bar
>ATR on a 1 min data stream but the result is a constant ( 5:00).
That's 'cause you copied from my email literally, and I was using
pseudo-code that looked like EasyLanguage. I'll go over it better
here, and copy to the Omega list in case others were confused.
A N-bar ATR on any data stream is simply atr=AverageTrueRange(N) for a
simple average. This is built into TS. An exponential average ATR
would be atr=w*TrueRange+(1-w)*atr[1], where w=2/(N+1).
If you want to simulate an N-bar ATR on (M*R)-minute bars, where M
is a multiple of your data stream resolution R, then you need to
calculate it as follows:
TR = MaxList(highest(H,M),C[M])
- MinList(lowest(L,M),C[M]); {True range of last M bars}
w = 2/(N*M+1); {exponential weighting factor}
ATR = w*TR + (1-w)*ATR[1]; {average true range}
In the case of a 10-bar ATR of 5-minute bars, calcuated on 1-minute
bars, you'd have N=10, M=5, R=1. In the case of, say, a 15-bar ATR
of 10-minute bars calculated on a data stream of 5-minute bars,
you'd have N=15, M=2, R=5 (remember M is a multiple of your data
stream resolution). Note that R isn't used anywhere, it's only for
you to figure out what your value of M must be.
>In the variable "w", is the 30 = timeframe and the 10 = bar length? I
>have a feeling this is where I am going wrong.
>
>My version:
>
> Range = Highest(5) - Lowest(5);
Two problems:
1. "Range" is a reserved word in EasyLanguage. Use some other name.
2. The Highest and Lowest functions take two arguments, price and
length. I neglected to include these in my earlier example.
-Alex
|