Repaints MTF True Momentum Osc - TMO3 For ThinkOrSwim

Repaints

dart966

Member
VIP
Here's another version of the TMO indicator by JohnnyQuotron .

Author states: TMO calculates momentum using the delta of price. Giving a much better picture of trend, trend 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 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. 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 probability is much greater that there will be a polarity change once price exits the squeeze.

This has a secondary aggregation (this portion will repaint) to help determine overall trend and Squeeze indicator was added to show areas of price compression:

16:25 Johnny_Quotron____: So I way playing with Mobius' TMO today…
16:54 AlphaInvestor: JQkpa - what did you change in Mobius' TMO ... changes are not noted
18:03 Johnny_Quotron____: @alpha.. the script is a work in progress.. the only hackeroo so far is the addition of the shorter length histo plot

TMO3_plus_Histo_JQ.png


Code:
## TMO3_plus_Histo_JQ
##  hacked from :
# TMO ((T)rue (M)omentum (O)scillator) V02  Really 03 JQ
# Mobius
# V03.07.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 probability is much greater that there will be a polarity change once price exits the squeeze.

# Note altered secondary plot for aggregations above daily
# 16:04 Mobius: Alpha - Just for you  :)

declare Lower;

input length = 14;    #DEFAULT 14
input CalcLength = 5;  #Mobius
input MA_CalcLength = 5;
input MA_CalcType = AverageType.EXPONENTIAL;
input smoothLength = 5;  # default 3
input MainSmootherLength = 3;    # default 3
input TriggerSmootherLength = 3;    # default 3
input AvgType = AverageType.Hull;
input MainSmootherType = AverageType.Hull;
input TriggerSmootherType = AverageType.Hull;
input ColorCandles = no;
input secAgg = AggregationPeriod.WEEK;

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, MA_calcLength);
def MA_data =  MovingAverage(AvgType, Data, MA_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.white
                       else if between(main, os, ob) and Main > Signal
                       then color.WHITE
                       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);

## HISTOGRAM
PLOT HistogramData = fold iH = 0 to rounddown(length/3, numberOfDigits = 0)
           with sH
           do sH + (if c > getValue(o, iH)
                   then 1
                   else if c < getValue(o, iH)
                        then - 1
                        else 0);
HistogramData.setPaintingStrategy(paintingStrategy.HISTOGRAM);
HistogramData.SetLineWeight(3);
HistogramData.DefineColor("Positive and Up", Color.GREEN);
HistogramData.DefineColor("Positive and Down", Color.DARK_GREEN);
HistogramData.DefineColor("Negative and Down", Color.RED);
HistogramData.DefineColor("Negative and Up", Color.DARK_RED);
HistogramData.AssignValueColor(if HistogramData >= 0
        then if HistogramData > HistogramData[1]
            then HistogramData.color("Positive and Up")
            else HistogramData.color("Positive and Down")
            else if HistogramData < HistogramData[1]
                then HistogramData.color("Negative and Down")
        else HistogramData.color("Negative and Up"));

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

## SQUEEZE NOTIFICATION
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();
addchartbubble(squeeze and !isnan(close) and isnan(close[-1]), 0, "squeeze", color.red, no);

 
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, MA_CalcLength);
plot Main_2 = MovingAverage(AvgType, EMA5_2, smoothLength);
     Main_2.EnableApproximation();
     Main_2.SetLineWeight(3);
     Main_2.SetDefaultColor(Color.Yellow);
# End Code
 
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
598 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