Relative Strength Grid For ThinkOrSwim

wtf_dude

Well-known member
Really wanted a "candle glance" type grid for index/stock/ industry type relative strength (not RSI) and couldn't find one. Just throwing it out there in case anybody finds it useful. Keep in mind the gray line is the XYZ:SPX ratio and not the price of the symbol you specify. You can change the comparison strength symbol through opening up the study. Its quite annoying you can't scale the indicator size as I have it setting right now which is a lower indicator moved up to the upper price chart but with the real symbols candles blacked out, so if anybody has a better suggestion, let's get it going. This definitely works in a pinch though. Orange is 200 sma, Red is 50 sma.

Relative Strength Candle Glance (share link)

15e52f36e12bcc63bbd82069dc720577.png
 
Really wanted a "candle glance" type grid for index/stock/ industry type relative strength (not RSI) and couldn't find one. Just throwing it out there in case anybody finds it useful. Keep in mind the gray line is the XYZ:SPX ratio and not the price of the symbol you specify. You can change the comparison strength symbol through opening up the study. Its quite annoying you can't scale the indicator size as I have it setting right now which is a lower indicator moved up to the upper price chart but with the real symbols candles blacked out, so if anybody has a better suggestion, let's get it going. This definitely works in a pinch though. Orange is 200 sma, Red is 50 sma.

Relative Strength Candle Glance (share link)

15e52f36e12bcc63bbd82069dc720577.png
I like this idea. I was trying to do something similar with labels. And I ended up doing the 9/21 instead of the 50/200. My labels are showing the Daily 9/21 plus the current timeframe 9/21. I will think about what you've done and maybe tinker a bit and post something this weekend.

RNlWqTW.png
 
Okay, tried playing around a bit with sectors and relative strength in comparison to the current symbol. The labels are green/red based on the 9/21 EMA. They go dark green/dark red if stronger/weaker than the current symbol. Here is what it looks like on SPX:

ycxbAIR.png


So...most of the sectors are stronger than SPX on the weekly and daily chart. If this is of interest to anyone, let me know and I will clean up the code and post it.
 
Okay, here is the label study I posted an image of above.
  • You can select any aggregation period and a 'display label' for that period (eg. Week or Wk or W).
  • Then select 6 symbols for comparison, the defaults are the ones in the image.
  • You can modify the EMA levels as well. I'm using 9/21 but you can make them 50/200, etc.
  • I like using emojis to save space. 🐂 and 🐻 are the ones I've used above but will simply print the symbol in the appropriate color if you do not add them.
  • And finally, there is an option to 'add space' in front of the labels if you add this multiple times or have another study that is showing labels.
Ruby:
# Multiple symbol EMA status and relative strength analysis
# Created by @tony_futures
input higherAgg = AggregationPeriod.DAY;
input aggDisplay = "Daily";
input ticker = "QQQ";
input ticker2 = "XLK";
input ticker3 = "XLF";
input ticker4 = "XLE";
input ticker5 = "XLY";
input ticker6 = "XLC";
input bullEmoji = "";
input bearEmoji = "";
input fastlength = 9;
input slowlength = 21;
DefineGlobalColor("green", CreateColor(94, 110, 59));
DefineGlobalColor("red", CreateColor(136, 93, 100));
DefineGlobalColor("darkgreen", Color.DARK_GREEN);
DefineGlobalColor("darkred", Color.DARK_RED);

# Daily Avg
def dailyPrice = close(symbol = ticker, period=higherAgg);
def DailyFastAvg = ExpAverage(dailyPrice, fastlength);
def DailySlowAvg = ExpAverage(dailyPrice, slowlength);
def dailyPrice2 = close(symbol = ticker2, period=higherAgg);
def DailyFastAvg2 = ExpAverage(dailyPrice2, fastlength);
def DailySlowAvg2 = ExpAverage(dailyPrice2, slowlength);
def dailyPrice3 = close(symbol = ticker3, period=higherAgg);
def DailyFastAvg3 = ExpAverage(dailyPrice3, fastlength);
def DailySlowAvg3 = ExpAverage(dailyPrice3, slowlength);
def dailyPrice4 = close(symbol = ticker4, period=higherAgg);
def DailyFastAvg4 = ExpAverage(dailyPrice4, fastlength);
def DailySlowAvg4 = ExpAverage(dailyPrice4, slowlength);
def dailyPrice5 = close(symbol = ticker5, period=higherAgg);
def DailyFastAvg5 = ExpAverage(dailyPrice5, fastlength);
def DailySlowAvg5 = ExpAverage(dailyPrice5, slowlength);
def dailyPrice6 = close(symbol = ticker6, period=higherAgg);
def DailyFastAvg6 = ExpAverage(dailyPrice6, fastlength);
def DailySlowAvg6 = ExpAverage(dailyPrice6, slowlength);

# Relative Strength
def RS = if dailyPrice == 0 then 0 else close(period=higherAgg)/dailyPrice;
def sr = CompoundValue("historical data" = RS, "visible data" = if isNaN(sr[1]) then RS else sr[1]);
def strong = RS > SR;
def weak = RS < SR;

def RS1 = if dailyPrice2 == 0 then 0 else close(period=higherAgg)/dailyPrice2;
def sr1 = CompoundValue("historical data" = RS1, "visible data" = if isNaN(sr1[1]) then RS1 else sr1[1]);
def strong1 = RS1 > SR1;
def weak1 = RS1 < SR1;

def RS2 = if dailyPrice3 == 0 then 0 else close(period=higherAgg)/dailyPrice3;
def sr2 = CompoundValue("historical data" = RS2, "visible data" = if isNaN(sr2[1]) then RS2 else sr2[1]);
def strong2 = RS2 > SR2;
def weak2 = RS2 < SR2;

def RS3 = if dailyPrice4 == 0 then 0 else close(period=higherAgg)/dailyPrice4;
def SR3 = CompoundValue("historical data" = RS3, "visible data" = if isNaN(SR3[1]) then RS3 else SR3[1]);
def strong3 = RS3 > SR3;
def weak3 = RS3 < SR3;

def RS4 = if dailyPrice5 == 0 then 0 else close(period=higherAgg)/dailyPrice5;
def SR4 = CompoundValue("historical data" = RS4, "visible data" = if isNaN(SR4[1]) then RS4 else SR4[1]);
def strong4 = RS4 > SR4;
def weak4 = RS4 < SR4;

def RS5 = if dailyPrice6 == 0 then 0 else close(period=higherAgg)/dailyPrice6;
def SR5 = CompoundValue("historical data" = RS5, "visible data" = if isNaN(SR5[1]) then RS5 else SR5[1]);
def strong5 = RS5 > SR5;
def weak5 = RS5 < SR5;

input addSpace = no;
AddLabel(addSpace,"   ", Color.CURRENT);

AddLabel(DailyFastAvg > DailySlowAvg,ticker + " " + aggDisplay + bullEmoji,if strong then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg < DailySlowAvg,ticker + " " + aggDisplay + bearEmoji,if weak then GlobalColor("darkred") else GlobalColor("red"));
AddLabel(DailyFastAvg2 > DailySlowAvg2,ticker2 + " " + aggDisplay + bullEmoji,if strong1 then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg2 < DailySlowAvg2,ticker2 + " " + aggDisplay + bearEmoji,if weak1 then GlobalColor("darkred") else GlobalColor("red"));
AddLabel(DailyFastAvg3 > DailySlowAvg3,ticker3 + " " + aggDisplay + bullEmoji,if strong2 then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg3 < DailySlowAvg3,ticker3 + " " + aggDisplay + bearEmoji,if weak2 then GlobalColor("darkred") else GlobalColor("red"));
AddLabel(DailyFastAvg4 > DailySlowAvg4,ticker4 + " " + aggDisplay + bullEmoji,if strong3 then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg4 < DailySlowAvg4,ticker4 + " " + aggDisplay + bearEmoji,if weak3 then GlobalColor("darkred") else GlobalColor("red"));
AddLabel(DailyFastAvg5 > DailySlowAvg5,ticker5 + " " + aggDisplay + bullEmoji,if strong4 then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg5 < DailySlowAvg5,ticker5 + " " + aggDisplay + bearEmoji,if weak4 then GlobalColor("darkred") else GlobalColor("red"));
AddLabel(DailyFastAvg6 > DailySlowAvg6,ticker6 + " " + aggDisplay + bullEmoji,if strong5 then GlobalColor("darkgreen") else GlobalColor("green"));
AddLabel(DailyFastAvg6 < DailySlowAvg6,ticker6 + " " + aggDisplay + bearEmoji,if weak5 then GlobalColor("darkred") else GlobalColor("red"));
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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