Repaints MTF Relative Strength For ThinkOrSwim

Repaints

ERHorner

New member
I found this Relative Strength Indicator in TradingView by a guy named Modhelius
https://www.tradingview.com/script/A4WyMCKM-Relative-Strength/
I was hoping someone could convert it to ThinkScript. I thought I would be able to, but cannot seem to replicate what I am looking for. My goal is to be able to input specific days (i.e. 260 days and 64 days) into the Indicator so that I can run both at the same time on my screen. Thank you for the help. Below is the code from TradingView:
 
Last edited by a moderator:
MTF Relative Strength Indicator for ThinkOrSwim

Ruby:
subgraph. This declaration is used when your study uses values that are considerably lower or higher than price history or volume values.
declare lower;

# User Inputs
input show_RSNHBP = yes; #Hint show_RSNHBP: Set to "Yes" to display RS New High Before Price (RSNHBP). The Pink Dot
input show_RSNH = yes; #Hint show_RSNH: Set to "Yes" to display RS New High. The Green Dot.

#Relative Strength Type - Candlestick to be added later.
input graphStyle = {default "Line"}; #Hint graphStyle: Only available format is Line.

#3 Month, 6 Month, 1 Year RS
input TimeFrame = {default "Three_Months", "Six_Months", "1_Year"}; #Hint TimeFrame: Select the appropriate timeframe to calculate Relative Strength.

#Index SymbolRelation
input CorrelationWithSecurity = "SPX"; #Hint CorrelationWithSecurity: Select appropriate Index against which Relative Strength will be calculated.

#Calculation TimeFrame
def aggregationperiod = AggregationPeriod.DAY;

#Chart Normalized Relative Strength Rating on Last Bar
def isLastBar = BarNumber() == HighestAll(if !IsNaN(close) then BarNumber() else Double.NaN);

#Turn on or off Alerts when cycling charts
input Alerts_On = yes; #Hint Alerts_On: Set to "Yes" to receive sound alerts when triggered.

#Add Chart Bubbble to Graph
input RS_Rating_ChartBubble = yes; #Hint RS_Rating_ChartBubble: Set to "Yes" to display current Normalized RS Rating (not the same as MarketSmith).

#Establish look back length:
def Length = if TimeFrame == TimeFrame.Three_Months then 63 else if TimeFrame == TimeFrame.Six_Months then 126 else 252;

#Get Index Close/Open/High/Low - Prep for Candlestick RS.
def indexopen = open(CorrelationWithSecurity, aggregationperiod);
def indexhigh = high(CorrelationWithSecurity, aggregationperiod);
def indexlow = low(CorrelationWithSecurity, aggregationperiod);
def indexclose = close(CorrelationWithSecurity, aggregationperiod);

#Get Relative Strength - Prep for Candlestick RS.
def RSopen = open / indexopen;
def RShigh = high / indexhigh;
def RSlow = low / indexlow;
def RSclose = close / indexclose;


#Normalize Relative Strength
def newRngMax = 99; #Maximum normalized value
def newRngMin = 1; #Minimum normalized value

def HHDataclose = HighestAll(RSclose);
def LLDataclose = LowestAll(RSclose);

plot normalizeRSclose = ((( newRngMax - newRngMin ) * ( RSclose - LLDataclose )) / ( HHDataclose - LLDataclose )) + newRngMin;


AddLabel(normalizeRSclose , Round(normalizeRSclose, 0), color.black);

AssignBackgroundColor( if normalizeRSclose >= 80 then Color.GREEN else color.black);

normalizeRSclose.assignValueColor (Color.black);
 
Last edited by a moderator:

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
562 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