In his article in this issue, “(Yet Another) Improved RSI,” John Ehlers explains how he enhances the RSI by taking advantage of Hann windowing. The RSIH indicator provides a smoother calculation than the classic RSI and has a zero mean. The inherent smoothing in the computation removes the need for supplemental filtering. The best length to use for the RSIH is described to be one that is on the order of the dominant cycle period in the data.
//Indicator: TASC DEC 2021 RSIH
// TASC JAN 2022
// RSIH - RSI with Hann Windowing
// (C) 2005-2021 John F. Ehlers
// Parameters
RSILength: 14
// Accumulate "Closes Up" and "Closes Down"
CU = 0
CD = 0
for count = 1 to RSILength do
if Close[count - 1] - Close[count] > 0 then
CU = CU + (1 - cos(360*count / (RSILength + 1))) * (Close[count - 1] - Close[count])
endif
if Close[count] - Close[count - 1] > 0 then
CD = CD + (1 - cos(360*count / (RSILength + 1))) *(Close[count] - Close[count - 1])
endif
next
if CU + CD <> 0 then
MyRSI = (CU - CD) / (CU + CD)
endif
return MyRSI as "RSIH"