I need help programming an RSI without the pre-existing “wilderaverage” function. The reason is that i have a few ideas about altering the relative strength formula. I have tried to do this myself but have not been successful.
Here’s the code, you can change it as best suits you:
// RSI custom
//
// (https://www.prorealcode.com/topic/indicatore-rsi/#post-51250)
// (https://www.investopedia.com/terms/r/rsi.asp)
//
// p = 14
p = max(1,min(p,999)) //2 - 999
Ob = 70
Os = 100 - Ob
//
// Determina le variazione giornaliere
rialzo = MAX(0, CLOSE - CLOSE[1])
ribasso = MAX(0, CLOSE[1] - CLOSE)
// Calcola la media dei guadagni i giorni di rialzo
// e delle perdite i gorni di ribasso
mmRialzo = WILDERAVERAGE[p](rialzo)
mmRibasso = WILDERAVERAGE[p](ribasso)
// En déduit le RS
RS = mmRialzo / mmRibasso
// E finalmente le RSI
mioRSI = 100 - (100 / (1 + RS))
RETURN mioRSI AS "Rsi",Os AS "Os",Ob AS "Ob", 50 as "Mid"
Thank you robertogozzi for that answer.
I have tryed to apply a golden ratio multiplier of 1.618 to all closing prices that go in to the formula but no mather how i write this code it just dosen’t seem to work. The program ignores the multiplier (1.618) and displayes regular RSI instead.
Do you have any idea of what it is i’m doing wrong, or is it simply not possible to apply a multiplier to the Prorealcode Wilderaverage function?
Here is my code:
//variation of closing prices
UPCLOSE = MAX(0, CLOSE - CLOSE[1])
DOWNCLOSE = MAX(0, CLOSE[1] - CLOSE)
//1.618 golden ratio multiplier to all closing prices
BULL = UPCLOSE * 1.618
BEAR = DOWNCLOSE * 1.618
//Average upcloses divided by average down closes
BULLAVERAGE = WILDERAVERAGE[14](BULL)
BEARAVERAGE = WILDERAVERAGE[14](BEAR)
RS = BULLAVERAGE/BEARAVERAGE
//Relative strength index formula
MYRSI = 100 - 100 / (1 + RS)
RETURN MYRSI, 30, 50, 70
It shouldn’t change anything.
If you have 14 closing prices RSI returns some data, If you multiply those prices for wahtever number you want RSI will always return the same result.
Example:
23 * 1 = 23
2 * 1 = 2
-------------
23 / 2 = 11.5
no matter if you multiply each number by two or else, the result will be the same (11.5):
23 * 2 = 46
2 * 2 = 4
-------------
46 / 4 = 11.5
Oh, now i understand, thank you 🙂
I have another question.
Is it possible to change the smoothening/dampening of RSI in pro realcode?
Smoothing any indicator means applying an average to it. So a smoothed RSI is quite simple:
MyRSI = Rsi[14](close) //standard RSI
SmoothedRSI = Average[10,1](MyRSI) //RSI smoothed with a 10-period EMA
RETURN MyRSI AS "Rsi",SmoothedRSI AS "Smoothed Rsi"