|
RSI compute help |
Posted by Gerson Luiz Ceccon on Mar-09-2011 02:53 |
|
Hello Peter
Can you please give me a example what you mean in computeRSI when you comment
//RSI is defined as the average up changes for the last 14 days, divided by the
//average absolute changes for the last 14 days, expressed as a percentage.
other literature express RSI = 100 * (prevGain/(prevGain+prevLoss)), but whan we have no gain or no loss in the period the formula above return a error "div/0"
Is you method different?
Thanks for the help. |
Re: RSI compute help |
Posted by Peter Kwan on Mar-09-2011 12:45 |
|
Hi Gerson,
The prevGain refers to the "average up changes for the last N days". If you think carefully, the "prevGain+prevLoss" is equivalent to the "average absolute changes for the last N days". So 100 * (prevGain/(prevGain+prevLoss)) is equivalent to the ChartDirector formula.
RSI, like many financial indicators, are mathematically inconsistent. (May be these indicators are not invented by mathematicians.) For example, it does not defined how to handle the case where the gain and lost are always zero (that is, the price never changes), in which case the formula produce the undefined value 100 * 0/0.
For a programmer, we must handle all these undefined cases to avoid the program from crashing. In ChartDirector, for RSI, the above case is specially handled and is assumed to be 50.
Hope this can help.
Regards
Peter Kwan |
Re: RSI compute help |
Posted by Gerson Luiz Ceccon on Mar-09-2011 20:42 |
|
Hi Peter
I understood but what will happening in the example bellow?
Ex:
Serie=[32,32,32,32,32,32,32,32,32,32,32,32,32,32,31.99]
Chartdir will treat the firsts 14 (no gain no loss) elements considering the RSI=50 but when a small change occur the RSI value jump from 50 to 100. Is that correct? Chartdir is treating this case also?
Can you please indicate the line number where ChartDir is treating no gain or no loss cases? I didn't found it.
Thanks in advance |
Re: RSI compute help |
Posted by Peter Kwan on Mar-09-2011 23:49 |
|
Hi Gerson,
This is absolutely correct and is in compliance with the commonly accepted RSI formula.
For the division operation in computeRSI, we use financial division (financeDiv), which will handle the division by zero case.
Hope this can help.
Regards
Peter Kwan |
|