# TradingView Convert John Ehlers Yet Another Improved RSI – RSIH

Status
Not open for further replies.

#### Takata

##### New member
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //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"

#### bigboss

##### Member
I took a stab at it. I don't know if I got the fold right and don't have a reference to compare against so... consider that.

Edited to fix the angle calculation in the cosine call and change the coloring algo to make more sense based on the smoothed result.

Code:
``````# Indicator: TASC DEC 2021 RSIH
# TASC JAN 2022
# RSIH - RSI with Hann Windowing
# (C) 2005-2021 John F. Ehlers
# Ported to thinkscript by bigboss

declare lower;
input RSILength = 14;
input over_bought = .7;
input over_sold = -.7;

# Accumulate "Closes Up" and "Closes Down"

def CU = fold i = 1 to RSILength+1
with CUC = 0
do
if getValue(Close,i - 1) - Close[i] > 0 then CUC + (1 - cos(2*Double.Pi*i / (RSILength + 1))) * (getValue(Close,i - 1) - Close[i]) else CUC;

def CD = fold j = 1 to RSILength
with CDC = 0
do
if Close[j] - getValue(Close,j - 1) > 0 then CDC + (1 - cos(2*Double.Pi*j / (RSILength + 1))) *(Close[j] - getValue(Close,j - 1)) else CDC;

plot RSIH =  (CU - CD) / (CU + CD);
plot overbought = over_bought;
plot oversold = over_sold;
plot zeroline = 0;

overbought.SetDefaultColor(COLOR.RED);
oversold.SetDefaultColor(COLOR.GREEN);
zeroline.SetDefaultColor(COLOR.GRAY);
RSIH.AssignValueColor(if RSIH < RSIH[1] then COLOR.RED else if RSIH > RSIH[1] then COLOR.GREEN else COLOR.WHITE);``````

Last edited:
Status
Not open for further replies.

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?