Ultimate Strength Index For ThinkOrSwim

xoxoJNN

New member
VIP
Author's notes:
  • The USI is a modified version of Wilder's original Relative Strength Index (RSI) that incorporates Ehlers' UltimateSmoother lowpass filter to produce an output with significantly reduced lag.
  • John Ehlers reformulated the RSI to substantially reduce lag by applying his UltimateSmoother filter to upward movements (strength up - SU) and downward movements (strength down - SD) in the time series, replacing the standard process of smoothing changes with rolling moving averages (RMAs).
  • Ehlers also modified the RSI formula to produce an index that ranges from -1 to +1 instead of 0 to 100.
  • As a result, the USI indicates bullish conditions when its value moves above 0 and bearish conditions when it falls below 0.
3ZRB7z2.png


Original Tradingview code
https://www.tradingview.com/script/NwmP4Iau-TASC-2024-11-Ultimate-Strength-Index/

Must scroll down to the next post for the new ThinkOrSwim code.


TT-Tradingview.gif
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I was doing some further reading recommended by thinkorswim on the “Technical Analysis of Stocks & Commodities” magazine website and came across their “Trader's Tips” section where they provide source code implementations for various platforms focusing on the month's featured article. They used to include converted codes for thinkorswim, but they haven't done so for a while, possibly due to the Schwab transition. Anyway, long story short, I found their TradingView's page and saw a lot of interesting scripts. One in particular was the Ultimate Strength Index (USI) indicator, introduced by John Ehlers in his article titled “Ultimate Strength Index (USI)” from the November 2024 edition of TASC's Traders' Tips. If it's not too much trouble, I would really appreciate it if anyone could help convert this indicator. Thank you in advance for your time. 🙏😄


AUTHOR'S NOTES:

  • The USI is a modified version of Wilder's original Relative Strength Index (RSI) that incorporates Ehlers' UltimateSmoother lowpass filter to produce an output with significantly reduced lag.
  • John Ehlers reformulated the RSI to substantially reduce lag by applying his UltimateSmoother filter to upward movements (strength up - SU) and downward movements (strength down - SD) in the time series, replacing the standard process of smoothing changes with rolling moving averages (RMAs).
  • Ehlers also modified the RSI formula to produce an index that ranges from -1 to +1 instead of 0 to 100.
  • As a result, the USI indicates bullish conditions when its value moves above 0 and bearish conditions when it falls below 0.

TRADINGVIEW:

https://www.tradingview.com/script/NwmP4Iau-TASC-2024-11-Ultimate-Strength-Index/


TT-Tradingview.gif
check the below:

CSS:
#// Indicator for TOS
#// © PineCodersTASC
#//  TASC Issue: November 2024
#//     Article: Less Lag, More Data
#//              Ultimate Strength Index (USI)
#//  Article By: John Elhers
#//    Language: TradingView's Pine Script™ v5
#// Provided By: PineCoders, for tradingview.com
#title ='TASC 2024.11 Ultimate Strength Index' stitle = 'USI'
# Converted by Sam4Cok@Samer800    - 11/2024
Declare lower;

input timeframe = AggregationPeriod.MIN;
input usiLength = 28; #, 'USI Length:', minval = 1)
input Source = FundamentalType.CLOSE; #, "Source")

def na = Double.NaN;
def last = isNaN(close);
def cap = GetAggregationPeriod();
def tf = Max(cap, timeframe);
def src = Fundamental(Source, Period = tf);
#// @function The UltimateSmoother is a filter created
Script UltimateSmoother {
input src = close;
input period = 14;
    def pi = Double.Pi;
    def a1 = exp(-1.414 * pi / period);
    def c2 = 2.0 * a1 * cos(1.414 * pi / period);
    def c3 = -a1 * a1;
    def c1 = (1.0 + c2 - c3) / 4.0;
    def us = CompoundValue(1, (1.0 - c1) * src +
              (2.0 * c1 - c2) * src[1] -
              (c1 + c3) * src[2] +
              c2 * us[1] + c3 * us[2], src);
    plot out = us;
}
#// @function Ultimate Strength Index is a new version of
Script UltimateStrengthIndex {
input src = close;
input l1 = 14;
input l2 = 4;
    def eps = TickSize();
    def diff = src - src[1];
    def SU = if diff > 0.0 then  diff else 0.0;
    def SD = if diff < 0.0 then -diff else 0.0;
    def avgSU = Average(SU, l2);
    def avgSD = Average(SD, l2);
    def USU = UltimateSmoother(avgSU, l1);
    def USD = UltimateSmoother(avgSD, l1);
    def USI = if (USU + USD) != 0 and USU > eps and USD > eps then (USU - USD) / (USU + USD) else USI[1];
    plot out = USI;
}

#// --- Calculations ---
def usi = UltimateStrengthIndex(src, usiLength);

def col = if isNaN(usi) then 0 else if usi > 1 then 1 else if usi < -1 then -1 else usi;
#-- plot
plot usiLine   = if last then na else usi; #, 'USI', #377eb8)
plot midLine   = if last then na else 0; #, 'Zero Line', color.silver)


usiLine.SetDefaultColor(Color.CYAN);
midLine.SetDefaultColor(Color.DARK_GRAY);

AddCloud(usiLine, midLine, Color.DARK_GREEN, Color.DARK_RED);
AddCloud(if col>= 0.4 then usiLine else na, 0.4, Color.DARK_GREEN);
AddCloud(if col<=-0.4 then -0.4 else na, usiLine, Color.DARK_RED);

#-- END of CODE
 
check the below:

CSS:
#// Indicator for TOS
#// © PineCodersTASC
#//  TASC Issue: November 2024
#//     Article: Less Lag, More Data
#//              Ultimate Strength Index (USI)
#//  Article By: John Elhers
#//    Language: TradingView's Pine Script™ v5
#// Provided By: PineCoders, for tradingview.com
#title ='TASC 2024.11 Ultimate Strength Index' stitle = 'USI'
# Converted by Sam4Cok@Samer800    - 11/2024
Declare lower;

input timeframe = AggregationPeriod.MIN;
input usiLength = 28; #, 'USI Length:', minval = 1)
input Source = FundamentalType.CLOSE; #, "Source")

def na = Double.NaN;
def last = isNaN(close);
def cap = GetAggregationPeriod();
def tf = Max(cap, timeframe);
def src = Fundamental(Source, Period = tf);
#// @function The UltimateSmoother is a filter created
Script UltimateSmoother {
input src = close;
input period = 14;
    def pi = Double.Pi;
    def a1 = exp(-1.414 * pi / period);
    def c2 = 2.0 * a1 * cos(1.414 * pi / period);
    def c3 = -a1 * a1;
    def c1 = (1.0 + c2 - c3) / 4.0;
    def us = CompoundValue(1, (1.0 - c1) * src +
              (2.0 * c1 - c2) * src[1] -
              (c1 + c3) * src[2] +
              c2 * us[1] + c3 * us[2], src);
    plot out = us;
}
#// @function Ultimate Strength Index is a new version of
Script UltimateStrengthIndex {
input src = close;
input l1 = 14;
input l2 = 4;
    def eps = TickSize();
    def diff = src - src[1];
    def SU = if diff > 0.0 then  diff else 0.0;
    def SD = if diff < 0.0 then -diff else 0.0;
    def avgSU = Average(SU, l2);
    def avgSD = Average(SD, l2);
    def USU = UltimateSmoother(avgSU, l1);
    def USD = UltimateSmoother(avgSD, l1);
    def USI = if (USU + USD) != 0 and USU > eps and USD > eps then (USU - USD) / (USU + USD) else USI[1];
    plot out = USI;
}

#// --- Calculations ---
def usi = UltimateStrengthIndex(src, usiLength);

def col = if isNaN(usi) then 0 else if usi > 1 then 1 else if usi < -1 then -1 else usi;
#-- plot
plot usiLine   = if last then na else usi; #, 'USI', #377eb8)
plot midLine   = if last then na else 0; #, 'Zero Line', color.silver)


usiLine.SetDefaultColor(Color.CYAN);
midLine.SetDefaultColor(Color.DARK_GRAY);

AddCloud(usiLine, midLine, Color.DARK_GREEN, Color.DARK_RED);
AddCloud(if col>= 0.4 then usiLine else na, 0.4, Color.DARK_GREEN);
AddCloud(if col<=-0.4 then -0.4 else na, usiLine, Color.DARK_RED);

#-- END of CODE
Thank you so much @samer800! You are awesome! 🙌
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
392 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top