This code snippet demonstrates how to implement an on-chart Relative Strength Index (RSI) with dynamic overbought and oversold levels using the ProBuilder language. The RSI is a popular momentum oscillator used in technical analysis that measures the speed and change of price movements.
//PRC_OnChart RSI | indicator
//25.10.2019
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
rsiperiod=14
ATRperiod = 20
maPeriod = 20
maMethod = 0
overBought = 70
overSold = 30
// --- end of settings
maPrice = customclose
dTR = 0
for i = 0 to ATRperiod-1
dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
next
avgRange = dTR/ATRperiod
maValue = average[maPeriod,maMethod](maPrice)
rsivalue = rsi[rsiperiod](maPrice)
//---- Buffer1=maValue
Buffer2=maValue+(avgRange*(overBought-50)/100)
Buffer3=maValue-(avgRange*(50- overSold)/100)
Buffer4=maValue+(rsivalue -50)/100*avgRange
return Buffer1 style(dottedline,1) as "mid level",
Buffer2 style(dottedline,1) as "overbought level",
Buffer3 style(dottedline,1) as "oversold level",
Buffer4 coloured(0,255,0) style(line,2) as "OnChart RSI"
Explanation of the Code:
This code is a practical example of how to enhance traditional RSI indicators by incorporating market volatility into the overbought and oversold levels, providing a more adaptive tool for technical analysis in trading systems.
Check out this related content for more information:
https://www.prorealcode.com/topic/rsi-sul-prezzo-2/#post-111226
Visit Link