PureBytes Links
Trading Reference Links
|
In some recent mails I read some things about division by
zero,
uncertainities, loss of sensitivity etc., referring to the RSI
formula.
Let us clear the subject to avoid
misunderstandings.
In Amibroker 3.70 Userīs Guide we have<FONT
size=2>
RSI=100-[100/(1+U/D)]
U = average of upward price closes (EMA of gains)D =
average of downward price closes (EMA of losses)
The formula 100-[100/(1+U/D)] is equivalent to
<FONT
size=2>
100*(U/(U+D))
which will never suffer from division by zero and any
uncertainity.
Above formula is, like any well defined formula, equally
sensitive
in its definition domain.
The only slight difference is that in built-in RSI, Wilders
average
is used instead of EMA stated above.
As for the U and D, it is not exactly an average of price
closes but
an average of price differences C-Ref(C,-1).
For a better AFL understanding, you may use the
code
/*RSI 12*/
<FONT color=#008000
size=2>t=12;Up=IIf(C>Ref(C,-1),abs(C-Ref(C,-1)),0);Dn=IIf(C<Ref(C,-1),abs(C-Ref(C,-1)),0);Ut=Wilders(Up,t);
<FONT color=#008000
size=2>Dt=Wilders(Dn,t);RSIt=100*(Ut/(Ut+Dt));Graph0=RSIt;
Above code will give the graph of built-in RSI(12)
function.
Dimitris Tsokakis
PS: It would be interesting to extend this in some future
edition
and have
RSI(Array,Periods=14)
and the same for
StochK(Array,Periods=14) and
StochD(Array,Periods=14)
This will give the possibility of easy reference to forms
like
RSI(High,12) or StochD(Low,20) etc., interesting for
Research.
RSI and Stochastic are interesting Mathematical tools and
may
be applied to any Array.
|