Trend Momentum Divergence Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
ubgTzu2.png


thinkScript Code

Rich (BB code):
#That will show mostly price within it's range compared to the indicator within it's range. Since the indicator is bound and price is free to run at any angle it please for as long is it damn well likes, it more or less will only allow you too see price against your indicator. If I was going to trade it on shorter timeframes, I would use this version

#

# Yet Another Divergence Script - Trend Momentum Divergence

# Nube 6.5.18

#hint: Usess linear of price scaled to RSI as an indicator of trend

declare lower;

input Length     = 14;

input OverBought = 70;

input OverSold   = 30;

input Cloud      = yes;

def na = Double.NaN;

def indicator  = RSI(Length = length);

script scale {

    input c = 0;

    input Min = 0;

    input Max = 1;

    def hh = HighestAll(c);

    def ll = LowestAll(c);

    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;

}

def sPrice = scale(close, Lowest(indicator, length), Highest(indicator, length));

plot 

OB  = if !IsNaN(close) then OverBought else na;

OB.SetDefaultColor(Color.Light_Red);

plot 

OS  = if !IsNaN(close) then OverSold else na;

OS.SetDefaultColor(Color.Light_Green);

plot 

RSI = indicator;

RSI.DefineColor("Over Bought", Color.Red);

RSI.DefineColor("Over Sold", Color.Green);

RSI.DefineColor("Typical", Color.White);

RSI.AssignValueColor(

if    RSI > OB 

then  RSI.color("Over Bought") 

else  if   RSI < overSold 

      then RSI.color("Over Sold") 

      else RSI.color("Typical")

);

plot 

priceTrend = Inertia(sPrice, length);

priceTrend.DefineColor("Price Trend Down", CreateColor(150,50,50));

priceTrend.DefineColor("Price Trend Up", CreateColor(50,150,50));

priceTrend.AssignValueColor(if   priceTrend < priceTrend[1]

                            then priceTrend.Color("Price Trend Down")

                            else priceTrend.Color("Price Trend Up"));

addCloud(if (cloud,rsi,na), priceTrend, 

CreateColor(50,150,50), CreateColor(150,50,50));

# f/ Trend Momentum Divergence

Shareable Link

https://tos.mx/qKnSH4
 
Last edited:
@Shrum
The Trend Momentum is a bound oscillator. Oscillator refers to the movement up over the midline (positive) or down (negative). Bounded refers to the upper and lower limits of the oscillator: Overbought is the upper red line, Oversold, is the lower green line. When the plot crosses above oversold, the bullish trend is beginning. When the plot crosses below overbought, it is ending.
 
Last edited:
Thank you @MerryDay , I guess I should have asked my question a little differently - I know one line is basically RSI and I am curious as to what the other line is measuring? Does that make sense? Thanks
 
@Shrum The faint red/green oscillating plot is the RSI. The bold white plot is the Trend Momentum line. It is calculated with the Inertia function.
This particular inertia plot is the linear regression curve of the RSI using the least-square approximation method.

Here is a thread that discusses the definition of inertia. You can use the search box to get dozens of other examples of its use.
https://usethinkscript.com/threads/what-is-inertia-and-inertiaall-from-linear-regression.1355/
 

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