Technical Rank (SCTR) Indicator for ThinkorSwim

Art

Member
I was looking at this SCTR indicator and it seems very interesting concept, here is more info https://www.investopedia.com/terms/s/stockcharts-technical-rank-sctr.asp https://school.stockcharts.com/doku.php?id=technical_indicators:sctr

Does anyone use something similar? What are your thoughts?

Code:
# SCTR
# DREWGRIFFITH15 (C) 2015

declare lower;

input SMA200 = 200;
input ROC125 = 125;
input SMA50 = 50;
input ROC20 = 20;
input PPO_HIST = 3;
input RSI = 14;
input LT_WEIGHT = .30;
input MD_WEIGHT = .15;
input SH_WEIGHT = .05;
input SR_LENGTH = 40;

# THIS STUDY IS A REPLICATION OF STOCKCHARTS TECHNICAL RANKING
# http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:sctr

#Long-Term Indicators (weighting)
#  * Percent above/below 200-day SMA (30%)
#  * 125-Day Rate-of-Change (30%)

def SM200 = SimpleMovingAvg(close, SMA200);
def LTSMA = ((close - SM200) / ((close + SM200) / 2));
def LTROC = RateOfChange(ROC125, close);
def LT = (LTSMA + LTROC) * LT_WEIGHT;

#Medium-Term Indicators (weighting)
#  * Percent above/below 50-day SMA  (15%)
#  * 20-day Rate-of-Change (15%)

def SM50 = SimpleMovingAvg(close, SMA50);
def MDSMA = ((close - SM50) / ((close + SM50) / 2));
def MDROC = RateOfChange(ROC20, close);
def MD = (MDSMA + MDROC) * MD_WEIGHT;

#Short-Term Indicators (weighting)
#  * 3-day slope of PPO-Histogram (5%)
#  * 14-day RSI (5%)

def EMA12 = MovAvgExponential(close, 12);
def EMA26 = MovAvgExponential(close, 26);
#def MACD = EMA12 - EMA26;
def PPO = (EMA12 - EMA26) / EMA26 * 100;
def PPOlinear = 6 * ( WMA(PPO, 3) -  Average(PPO, 3)) / (3 - 1);

# Mutliplier to get values between 0-100

def PPOdiff = PPOlinear - PPOlinear[1];
def NetChgAvg = SimpleMovingAvg(PPOdiff, 3);
def TotChgAvg = SimpleMovingAvg(AbsValue(PPOdiff), 3);
def ChgRatio = If(TotChgAvg != 0, (NetChgAvg / TotChgAvg), 0);

def SHPPO = Round(50 * (ChgRatio + 1), 3) / 100;
def SHRSI = reference RSI();
def SH = (SHPPO + SHRSI) * SH_WEIGHT;

def TR = Round(LT + MD + SH, NUMBEROFDIGITS = 1);

plot SCTR = if IsNaN(TR) then 0 else TR;

plot LONG_SR_HIGH = Round(Highest(SCTR, LENGTH = SR_LENGTH), NUMBEROFDIGITS = 1);

plot LONG_SR_LOW = Round(Lowest(SCTR, LENGTH = SR_LENGTH), NUMBEROFDIGITS = 1);

plot ZERO = 0;

SCTR.AssignValueColor(if SCTR >= ZERO then Color.GREEN else Color.RED);
SCTR.SetLineWeight(1);
SCTR.SetStyle(Curve.POINTS);

ZERO.AssignValueColor(if SCTR >= ZERO then Color.GREEN else Color.RED);
ZERO.SetLineWeight(3);
ZERO.SetStyle(Curve.POINTS);
ZERO.Hide();

LONG_SR_HIGH.SetDefaultColor(Color.CYAN);
#LONG_SR_HIGH.SetStyle(Curve.SHORT_DASH);
LONG_SR_HIGH.SetLineWeight(1);
LONG_SR_HIGH.Hide();

LONG_SR_LOW.SetDefaultColor(Color.CYAN);
#LONG_SR_LOW.SetStyle(Curve.SHORT_DASH);
LONG_SR_LOW.SetLineWeight(1);
LONG_SR_LOW.Hide();

### $$$ ###
 

Emrys

New member
I have been trying to use this script, but some stocks are showing more than 100.
The problem comes from at least these two lines:

Code:
def LTSMA = ((close - SM200) / ((close + SM200) / 2));

Code:
def MDSMA = ((close - SM50) / ((close + SM50) / 2));

If a close is 100 and SMA200 is 50, then LTSMA will be 50 / 75 = 0.667.
If a close is 150 and SMA200 is 50, then LTSMA will be 100 / 100 = 1.
If a close is 250 and SMA200 is 50, then LTSMA will be 200 / 150 =1.33
Same problem for MDSMA as it follows the same logic.

Thus, LTSMA and MDSMA can disproportionately add extra weighting to final scores when stock price skyrockets.
In other words, when stock price increases quickly, the score generated by this script can reach several hundreds.

According to a SctockCharts web page (https://school.stockcharts.com/doku.php?id=technical_indicators:sctr),
they convert scores to 0.00 - 99.99 ranking by comparing with each other.
I have not found a better way to convert the scores on TOS.
 
Last edited by a moderator:

JE $$

Member
I've been trying to put this in a watchlist column to simply display the value of the SCTR - all i can get is the lower indicator to appear when i use it as a study. if i past the script into the custom watchlist it says exactly one plot expected - i think its a simple fix but for the life of me cant get it to work - can anyone give some adivce?
 

Joshua

Well-known member
VIP
I've been trying to put this in a watchlist column to simply display the value of the SCTR - all i can get is the lower indicator to appear when i use it as a study. if i past the script into the custom watchlist it says exactly one plot expected - i think its a simple fix but for the life of me cant get it to work - can anyone give some adivce?
Change Plot to Def everywhere except for with SCTR, and delete all the stuff at the bottom related to the unused plots.
 

MichDopo

New member
I've been trying to put this in a watchlist column to simply display the value of the SCTR - all i can get is the lower indicator to appear when i use it as a study. if i past the script into the custom watchlist it says exactly one plot expected - i think its a simple fix but for the life of me cant get it to work - can anyone give some adivce?
I was able to get it to work as a watchlist column with this code, but I will say I do not find it replicates the values given with SCTR:

#Code:
# SCTR
# DREWGRIFFITH15 (C) 2015, as modified by MichDopo Feb2022

declare lower;

input SMA200 = 200;
input ROC125 = 125;
input SMA50 = 50;
input ROC20 = 20;
input PPO_HIST = 3;
input RSI = 14;
input LT_WEIGHT = .30;
input MD_WEIGHT = .15;
input SH_WEIGHT = .05;
input SR_LENGTH = 40;

# THIS STUDY IS A REPLICATION OF STOCKCHARTS TECHNICAL RANKING
# http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:sctr

#Long-Term Indicators (weighting)
# * Percent above/below 200-day SMA (30%)
# * 125-Day Rate-of-Change (30%)

def SM200 = SimpleMovingAvg(close, SMA200);
def LTSMA = ((close - SM200) / ((close + SM200) / 2));
def LTROC = RateOfChange(ROC125, close);
def LT = (LTSMA + LTROC) * LT_WEIGHT;

#Medium-Term Indicators (weighting)
# * Percent above/below 50-day SMA (15%)
# * 20-day Rate-of-Change (15%)

def SM50 = SimpleMovingAvg(close, SMA50);
def MDSMA = ((close - SM50) / ((close + SM50) / 2));
def MDROC = RateOfChange(ROC20, close);
def MD = (MDSMA + MDROC) * MD_WEIGHT;

#Short-Term Indicators (weighting)
# * 3-day slope of PPO-Histogram (5%)
# * 14-day RSI (5%)

def EMA12 = MovAvgExponential(close, 12);
def EMA26 = MovAvgExponential(close, 26);
#def MACD = EMA12 - EMA26;
def PPO = (EMA12 - EMA26) / EMA26 * 100;
def PPOlinear = 6 * ( WMA(PPO, 3) - Average(PPO, 3)) / (3 - 1);

# Mutliplier to get values between 0-100

def PPOdiff = PPOlinear - PPOlinear[1];
def NetChgAvg = SimpleMovingAvg(PPOdiff, 3);
def TotChgAvg = SimpleMovingAvg(AbsValue(PPOdiff), 3);
def ChgRatio = If(TotChgAvg != 0, (NetChgAvg / TotChgAvg), 0);

def SHPPO = Round(50 * (ChgRatio + 1), 3) / 100;
def SHRSI = reference RSI();
def SH = (SHPPO + SHRSI) * SH_WEIGHT;

def TR = Round(LT + MD + SH, NUMBEROFDIGITS = 1);

plot SCTR = if IsNaN(TR) then 0 else TR;

SCTR.AssignValueColor(if SCTR >= 0 then Color.GREEN
else Color.RED);
SCTR.SetLineWeight(1);
SCTR.SetStyle(Curve.POINTS);

### $$$ ###
 

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.
Top