This code snippet demonstrates how to implement a Relative Strength Index (RSI) indicator in ProBuilder, which can be displayed with or without its traditional 0-100% scale. The RSI is a popular momentum oscillator used in technical analysis that measures the speed and change of price movements.
// RSI custom (with & without scale)
// (https://www.prorealcode.com/topic/indicatore-rsi/#post-51250)
// (https://www.investopedia.com/terms/r/rsi.asp)
//
// p = 14 //periods
p = max(1,min(p,999)) //1 - 999
Ob = 70 //OverBought
Os = 100 - Ob //OverSold
Middle = 50 //mean line
//
// r = 0
// g = 0
// b = 255
// t = 255
//
// Bullish = MAX(0, CLOSE - CLOSE[1])
// Bearish = MAX(0, CLOSE[1] - CLOSE)
//
// mmBullish = WILDERAVERAGE[p](Bullish)
// mmBearish = WILDERAVERAGE[p](Bearish)
//
// RS = mmBullish / mmBearish
IF ScaleEnabled THEN
myRSI = 100 - (100 / (1 + RS)) //scale
ELSE
MyRSI = RS //no scale
t = 0
Ob = MyRSI
Os = MyRSI
Middle = MyRSI
ENDIF
//
// RETURN MyRSI AS "Rsi",Os coloured(r,g,b,t) AS "Os",Ob coloured(r,g,b,t) AS "Ob", Middle coloured(r,g,b,t) as "Mid"
The code snippet above is structured to calculate and display the RSI in two modes: scaled and unscaled. Here’s a breakdown of its components:
This example is useful for understanding conditional statements and custom indicator development in ProBuilder.
Check out this related content for more information:
https://www.prorealcode.com/topic/modification-rsi/#post-153896
Visit Link