ElitePerformers For ThinkOrSwim

justAnotherTrader

Active member
VIP
VIP Enthusiast
Hi Traders!
We live in a really exciting time of AI, and honestly, I am looking forward to seeing how AI can make us better traders. Personally, I love chatGPT and have paired my market curiosity with its ability to reason to hopefully bring some novel indicators for you guys. However, in my attempts to be novel, I might make something a) Completely useless and b) inadvertently copy someone else's stuff. I always use my own indicators, sometimes not until after I share them, though. I hope you enjoy

What is it?
This indicator tracks a stock’s cumulative relative strength compared to a selected market or sector ETF. It helps identify whether the stock is consistently outperforming or underperforming its benchmark over time by plotting the daily change in their price ratio.

How to use it?
To use it, add the script to your chart and select the benchmark ETF (like SPY, QQQ, or SOXX) from the dropdown to compare your stock’s performance. A rising line indicates consistent outperformance, while a falling line shows underperformance.


To add more benchmarks, simply extend the dropdown list and etfClose logic with new symbols (e.g., add else if marketETF == marketETF."SOXX" then close("SOXX")).

What makes this a different perspective?
What makes this indicator unique is that it accumulates the daily relative performance, showing not just momentary strength but the long-term trend of outperformance or underperformance. Unlike traditional relative strength indicators, this version offers a smoother, more intuitive view of how a stock stacks up against a chosen benchmark over time.

bAbgABm.png


Code:
declare lower;

input marketETF = {default "SPY", "QQQ", "DIA", "IWM", "TAN", "XLK", "XLF", "SMH"};
input showThresholds = yes;
input thresholdLevel = 0.05;


# Correct ETF close price
def etfClose =
       if marketETF == marketETF."SPY" then close("SPY")
    else if marketETF == marketETF."QQQ" then close("QQQ")
    else if marketETF == marketETF."DIA" then close("DIA")
    else if marketETF == marketETF."IWM" then close("IWM")
    else if marketETF == marketETF."TAN" then close("TAN")
    else if marketETF == marketETF."XLK" then close("XLK")
    else if marketETF == marketETF."XLF" then close("XLF")
    else if marketETF == marketETF."SMH" then close("SMH")
    else close;


# Relative performance ratio
def ratio = close / etfClose;

# ✅ Correct delta = change in ratio, not offset from 1.0
def delta = ratio - ratio[1];
def cumDelta = if IsNaN(cumDelta[1]) then 0 else cumDelta[1] + delta;

# Plot cumulative relative strength
plot CumRelativeStrength = cumDelta;
CumRelativeStrength.SetLineWeight(2);
CumRelativeStrength.AssignValueColor(if cumDelta > 0 then Color.GREEN else if cumDelta < 0 then Color.RED else Color.GRAY);

# Optional reference lines
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.LIGHT_GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot UpperThresh = if showThresholds then thresholdLevel else Double.NaN;
plot LowerThresh = if showThresholds then -thresholdLevel else Double.NaN;
UpperThresh.SetDefaultColor(Color.LIGHT_GREEN);
UpperThresh.SetStyle(Curve.SHORT_DASH);
LowerThresh.SetDefaultColor(Color.PINK);
LowerThresh.SetStyle(Curve.SHORT_DASH);
 

Attachments

  • Screenshot From 2025-04-30 11-24-36.png
    Screenshot From 2025-04-30 11-24-36.png
    93.6 KB · Views: 101
Last edited by a moderator:

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

Hi Traders!
We live in a really exciting time of AI and honestly I am looking forward to seeing how AI can make us better traders. Personally I love chatGPT and have paired my market curiousity with its ability to reason to hopefully bring some novel indicators for you guys. However, in my attempts to be novel I might make something a) Completely useless and b) inadvertently copy someone elses stuff. I always use my own indicators, sometimes not until after I share them though. I hope you enjoy

What is it?
This indicator tracks a stock’s cumulative relative strength compared to a selected market or sector ETF. It helps identify whether the stock is consistently outperforming or underperforming its benchmark over time by plotting the daily change in their price ratio.

How to use it?
To use it, add the script to your chart and select the benchmark ETF (like SPY, QQQ, or SOXX) from the dropdown to compare your stock’s performance. A rising line indicates consistent outperformance, while a falling line shows underperformance.


To add more benchmarks, simply extend the dropdown list and etfClose logic with new symbols (e.g., add else if marketETF == marketETF."SOXX" then close("SOXX")).

What makes this a different perspective?
What makes this indicator unique is that it accumulates the daily relative performance, showing not just momentary strength but the long-term trend of outperformance or underperformance. Unlike traditional relative strength indicators, this version offers a smoother, more intuitive view of how a stock stacks up against a chosen benchmark over time.

4hr0t2i
bAbgABm.png


Code:
declare lower;

input marketETF = {default "SPY", "QQQ", "DIA", "IWM", "TAN", "XLK", "XLF", "SMH"};
input showThresholds = yes;
input thresholdLevel = 0.05;


# Correct ETF close price
def etfClose =
       if marketETF == marketETF."SPY" then close("SPY")
    else if marketETF == marketETF."QQQ" then close("QQQ")
    else if marketETF == marketETF."DIA" then close("DIA")
    else if marketETF == marketETF."IWM" then close("IWM")
    else if marketETF == marketETF."TAN" then close("TAN")
    else if marketETF == marketETF."XLK" then close("XLK")
    else if marketETF == marketETF."XLF" then close("XLF")
    else if marketETF == marketETF."SMH" then close("SMH")
    else close;


# Relative performance ratio
def ratio = close / etfClose;

# ✅ Correct delta = change in ratio, not offset from 1.0
def delta = ratio - ratio[1];
def cumDelta = if IsNaN(cumDelta[1]) then 0 else cumDelta[1] + delta;

# Plot cumulative relative strength
plot CumRelativeStrength = cumDelta;
CumRelativeStrength.SetLineWeight(2);
CumRelativeStrength.AssignValueColor(if cumDelta > 0 then Color.GREEN else if cumDelta < 0 then Color.RED else Color.GRAY);

# Optional reference lines
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.LIGHT_GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot UpperThresh = if showThresholds then thresholdLevel else Double.NaN;
plot LowerThresh = if showThresholds then -thresholdLevel else Double.NaN;
UpperThresh.SetDefaultColor(Color.LIGHT_GREEN);
UpperThresh.SetStyle(Curve.SHORT_DASH);
LowerThresh.SetDefaultColor(Color.PINK);
LowerThresh.SetStyle(Curve.SHORT_DASH);
Very nice! Thanks for sharing.
 
I'm not an expert coder even though I've modified some codes to get unique indicators. How do you get it to act as a color-coded watchlist column?
Honestly its not acting like I thought it would. It might still have some value but it seems to be updating off the intraday ticks and not daily like I want it to. Here it is if you want to try it. It may be a limitation of TOS or my coding, not sure:

Code:
def length = 63;
def stockReturn = close / close[length] - 1;
def spyReturn = close("SPY") / close("SPY")[length] - 1;
def relPerf = stockReturn - spyReturn;

AddLabel(yes,
    if relPerf > 0.10 then "Elite"
    else if relPerf > 0.05 then "Strong"
    else if relPerf > 0.01 then "Good"
    else if relPerf < -0.10 then "Terrible"
    else if relPerf < -0.05 then "Weak"
    else if relPerf < -0.01 then "Soft"
    else "Neutral",

    if relPerf > 0.10 then Color.DARK_GREEN
    else if relPerf > 0.05 then Color.GREEN
    else if relPerf > 0.01 then Color.LIGHT_GREEN
    else if relPerf < -0.10 then Color.DARK_RED
    else if relPerf < -0.05 then Color.RED
    else if relPerf < -0.01 then Color.LIGHT_RED
    else Color.GRAY
);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
447 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