TMO Trend & Squeeze For ThinkOrSwim

useThinkScript

Administrative
Staff member
Staff
VIP
Lifetime
Mobius states:
The TMO calculates momentum using the delta of price.
Price delta gauges the change rate, providing a dynamic view of direction and intensity. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

Secondary aggregation to help determine overall trend.
Trades when secondary aggregation is at extremes and primary aggregation signals a trade at extremes have a higher probability of extended gains.​
A 10 times +- difference in aggregation between the chart aggregation and the secondary aggregation gives adequate higher aggregation view of trend.

Signal lines (vertical green lines) are plotted for LONG trades only.

Squeeze indicator was added to show areas of price compression.
If squeeze is indicated and secondary aggregation stays in trend, look for price to continue after exiting squeeze in the same trend as prior to squeeze.​
If primary is rolling over or already at extremes, the probability is much greater that there will be a polarity change once price exits the squeeze.​
0tAu64Q.png


Ruby:
# TMO ((T)rue (M)omentum (O)scillator) Trend&SqueezeV02
# Mobius
# V02.04.2020
#hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.
# Revision: Added secondary aggregation to help determine overall trend. Trades when secondary aggregation is at extremes and primary aggregation signals a trade at extremes have a higher probablility of extended gains. A 10 times +- difference in aggregation between the chart aggregation and the seocndary aggregation gives adequate higher aggregation view of trend. Signal lines (vertical green lines) are plotted for long trades only. The indicator can be used as both a lower and upper study with all plots on the upper study converted to definitions and painting strategies commented out. Squeeze indicator was added to show areas of price compression. If squeeze is indicated and secondary aggregation stays in trend look for price to continue after exiting squeeze in same trend as prior to squeeze. If primary is rolling over or already at extremes the probility is much greater that there will be a polarity change once price exits the squeeze.

declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input AvgType = AverageType.Hull;
input ColorCandles = no;
input secAgg = AggregationPeriod.Hour;

 
def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and getTime() <= RegularTradingEnd(getYYYYMMDD());
def o = open;
def h = high;
def l = low;
def c = close;
def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);

def EMA5 = ExpAverage(data, calcLength);
plot Main = MovingAverage(AvgType, EMA5, smoothLength);
plot Signal = MovingAverage(AvgType, Main, smoothLength);
plot zero = if isNaN(c) then double.nan else 0;
     zero.SetDefaultColor(Color.gray);
     zero.hideBubble();
     zero.hideTitle();

plot ob = if isNaN(c) then double.nan else round(length * .7);
     ob.SetDefaultColor(Color.gray);
     ob.HideBubble();
     ob.HideTitle();

plot os = if isNaN(c) then double.nan else -round(length * .7);
     os.SetDefaultColor(Color.gray);
     os.HideBubble();
     os.HideTitle();

 Main.AssignValueColor(if Main > ob
                       then color.cyan
                       else if between(main, os, ob) and Main > Signal
                       then color.cyan
                       else if between(main, os, ob) and Main < Signal
                       then color.blue
                       else if Main < os
                       then color.blue
                       else color.blue);

     Main.HideBubble();
     Main.HideTitle();
     Signal.AssignValueColor(if Main > ob
                             then color.cyan
                             else if between(main, os, ob) and Main > Signal
                             then color.cyan
                             else if between(main, os, ob) and Main < Signal
                             then color.blue
                             else if Main < os
                             then color.blue
                             else color.blue);
     Signal.HideBubble();
     Signal.HideTitle();

addCloud(Main, Signal, color.cyan, color.blue);
addCloud(ob, length, color.light_green, color.light_green, no);
addCloud(-length, os, color.light_red, color.light_red);

AssignPriceColor(if ColorCandles and Main > Signal
                 then color.green
                 else if ColorCandles and Main < Signal
                 then color.red
                 else color.current);

plot squeeze = if(log(sum(TrueRange(h,c,l), 8) / (highest(h, 8) - lowest(l, 8))) / log(8) > .618, 0, double.nan);
     squeeze.SetStyle(Curve.Points);
     squeeze.SetLineWeight(3);
     squeeze.SetDefaultColor(Color.Red);
     squeeze.HideBubble();
     squeeze.HideTitle();

addVerticalLine(RTH and Main crosses above os, "", color.green);

def o2 = open(period = secAgg);
def h2 = high(period = secAgg);
def l2 = low(period = secAgg);
def c2 = close(period = secAgg);
def data2 = fold i2 = 0 to length
            with s2
            do s2 + (if c2 > getValue(o2, i2)
                    then 1
                    else if c2 < getValue(o2, i2)
                         then - 1
                         else 0);

def EMA5_2 = ExpAverage(data2, calcLength);
plot Main_2 = if getTime() % secAgg == 0
              then MovingAverage(AvgType, EMA5_2, smoothLength)
              else double.nan;
     Main_2.EnableApproximation();
     Main_2.SetLineWeight(3);
     Main_2.SetDefaultColor(Color.Yellow);

# End Code

per member request: @Phatrook
 
Last edited:
Is the above code updated to reflect this update ?
Here's the updated code below:

#Start_TMO_CODE_Created_By_Mobius**********
#Found here https://usethinkscript.com/threads/tmo-true-momentum-oscillator-for-thinkorswim.9413/
# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

def length = 14;
def calcLength = 5;
def smoothLength = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i) then 1 else if c < getValue(o, i) then - 1 else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def zero = if isNaN(c) then double.nan else 0;
def ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);
#End_TMO_CODE*_Created_By_Mobius***********

#****************************************************************************************************
#Defining Conditions - a change in momemtum and TMO os/ob levels

#Bullish Signal
def SH = TTM_Squeeze().Histogram;
def HistogramUp = if SH[0] > SH[1] then 1 else 0;
def TMO_MomentumUp = Main <= os and HistogramUP or Main <=os and HistogramUp;
def BullSignal = !TMO_MomentumUp[1] and TMO_MomentumUp;

#Bearish Signal
def HistogramDown = if SH[0] < SH[1] then 1 else 0;
def TMO_MomentumDown = Main >= ob and HistogramDown or Main >=ob and HistogramDown;
def BearSignal = !TMO_MomentumDown[1] and TMO_MomentumDown;

AddLabel(yes, if BullSignal then "Calls" else if BearSignal then "Puts" else " ");
AddLabel(BullSignal, "Calls", color.black);
AddLabel(BearSignal, "Puts", color.black);
AssignBackgroundColor(if BullSignal then color.light_green else if BearSignal then color.pink else color.black);
 
How do you get the study to be a column on the scan/watchlist table?
Click on the gear icon on the watchlist table then select Custom
on the drop down list under "Available Items" select Custom Quotes then select one of the Custom study then click Add Items
then on the right side, under "Current Set" click on the scroll icon next to the Custom study and paste in the code
then on the top give it a name. You can change the "D" for a shorter time frame if you want.

I hope this helps.
 
Can someone post the TMO Oscillator that has the squeeze on it and the trend line. The color was blue with the actual indicator. Thanks in advance......
 
I installed the indicator ok on TOS.

On the example above, are the red dots displaying the squeeze?

I have gone thru numerous tickers and I get no red dots. Do I have a configuration error of some sort"

Thanks,
 
I installed the indicator ok on TOS.

On the example above, are the red dots displaying the squeeze?

I have gone thru numerous tickers and I get no red dots. Do I have a configuration error of some sort"

Thanks,
I also do not seem to be getting the vertical green lines on the lower indicator.......
 

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