Multi-Time Frame True Momentum Oscillator (MTF) for ThinkorSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Someone modified the TMO MTF script for me to alert me audibly and visually when the 5 and 15 minute are in synch and it works really well. Simply go long or short when it tells you to. I've learned that it works best to go long when the 5 and 15 minute are coming up from -10, and go short when the 5 and 15 minute are coming down from +10.

Code:
# 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.

declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg1 = AggregationPeriod.FIFTEEN_MIN;
input agg2 = AggregationPeriod.FIVE_MIN;


def o = open(period = agg1);
def o1 = open(period = agg2);
def c = close(period = agg1);
def c1 = close(period = agg2);
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 data1 = fold i1 = 0 to length
            with s1
            do s1 + (if c1 > getValue(o1,i1)
                    then 1
                    else if c1 < getValue(o1,i1)
                         then - 1 else 0);

def EMA5 = ExpAverage(data, calcLength);
def EMA5_1 = ExpAverage(data1, calcLength);
plot Main = ExpAverage(EMA5, smoothLength);
plot Main_1 = ExpAverage(EMA5_1, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
plot Signal_1 = ExpAverage(Main_1, smoothLength);
     Main.AssignValueColor(if Main > Signal
                           then color.green
                           else color.red);
     Main_1.AssignValueColor(if Main_1 > Signal_1
                           then color.green
                           else color.red);

     Signal.AssignValueColor(if Main > Signal
                             then color.green
                             else color.red);
     Signal_1.AssignValueColor(if Main_1 > Signal_1
                             then color.green
                             else color.red);
     Signal.HideBubble();
     Signal.HideTitle();
     Signal_1.HideBubble();
     Signal_1.HideTitle();
addCloud(Main, Signal, color.green, color.red);
addCloud(Main_1, Signal_1, color.green, color.red);
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();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);

plot buydot = if Main > Signal and Main_1 > Signal_1 then -length - 1 else double.nan;
buydot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.ARROW_UP);
buydot.SetDefaultColor(Color.GREEN);

plot selldot = if Main < Signal and Main_1 < Signal_1 then length + 1 else double.nan;
selldot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.ARROW_DOWN);
selldot.SetDefaultColor(Color.RED);
def BUYsignal = Main crosses above Signal;
def SELLsignal = Main crosses below Signal;
addverticalline(BUYsignal,"Buy",color.green,curve.firm);
addverticalline(SELLsignal,"Sell",color.red,curve.firm);
# Alerts
Alert(BuySignal, " ", Alert.Bar, Sound.Chimes);
Alert(SellSignal, " ", Alert.Bar, Sound.Bell);
# End Code TMO
 
Can someone please add a dark red cloud when these 4 are overbought and if all 4 oversold at same time dark green cloud these are the 4
STCTREND, STCWAVE ,AGG1and AGG2. this is the TMO study THANKS http://tos.mx/4VCHpWX
m8JxGNf.png
 
Last edited:
Someone modified the TMO MTF script for me to alert me audibly and visually when the 5 and 15 minute are in synch and it works really well. Simply go long or short when it tells you to. I've learned that it works best to go long when the 5 and 15 minute are coming up from -10, and go short when the 5 and 15 minute are coming down from +10.

Code:
# 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.

declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg1 = AggregationPeriod.FIFTEEN_MIN;
input agg2 = AggregationPeriod.FIVE_MIN;


def o = open(period = agg1);
def o1 = open(period = agg2);
def c = close(period = agg1);
def c1 = close(period = agg2);
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 data1 = fold i1 = 0 to length
            with s1
            do s1 + (if c1 > getValue(o1,i1)
                    then 1
                    else if c1 < getValue(o1,i1)
                         then - 1 else 0);

def EMA5 = ExpAverage(data, calcLength);
def EMA5_1 = ExpAverage(data1, calcLength);
plot Main = ExpAverage(EMA5, smoothLength);
plot Main_1 = ExpAverage(EMA5_1, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
plot Signal_1 = ExpAverage(Main_1, smoothLength);
     Main.AssignValueColor(if Main > Signal
                           then color.green
                           else color.red);
     Main_1.AssignValueColor(if Main_1 > Signal_1
                           then color.green
                           else color.red);

     Signal.AssignValueColor(if Main > Signal
                             then color.green
                             else color.red);
     Signal_1.AssignValueColor(if Main_1 > Signal_1
                             then color.green
                             else color.red);
     Signal.HideBubble();
     Signal.HideTitle();
     Signal_1.HideBubble();
     Signal_1.HideTitle();
addCloud(Main, Signal, color.green, color.red);
addCloud(Main_1, Signal_1, color.green, color.red);
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();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);

plot buydot = if Main > Signal and Main_1 > Signal_1 then -length - 1 else double.nan;
buydot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.ARROW_UP);
buydot.SetDefaultColor(Color.GREEN);

plot selldot = if Main < Signal and Main_1 < Signal_1 then length + 1 else double.nan;
selldot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.ARROW_DOWN);
selldot.SetDefaultColor(Color.RED);
def BUYsignal = Main crosses above Signal;
def SELLsignal = Main crosses below Signal;
addverticalline(BUYsignal,"Buy",color.green,curve.firm);
addverticalline(SELLsignal,"Sell",color.red,curve.firm);
# Alerts
Alert(BuySignal, " ", Alert.Bar, Sound.Chimes);
Alert(SellSignal, " ", Alert.Bar, Sound.Bell);
# End Code TMO
Is there a way to add a 12-hour time frame? I tried editing the "input agg1" with no luck. Sorry in advance if I posted my request incorrectly still getting the swing of things on the forum.
 
@Gorby
I am not sure you are going to generate a great deal of enthusiasm for another multi-timeframe momentum oscillator given some of the awesome ones such as the MTF TMO and so many others on this forum.

Have you been using this oscillator? If you really want to garner some interest in this indicator, your best bet would be to explain in detail why you think this one is so superior to the others on this forum and to illustrate with screenshots: the comparisons, and differences between yours and the others on the forum. When you put effort into providing the images, the differences, and explaining how this will improve our trading. It makes it feel more like a team effort. Then armed with all those details, some enterprising poster might become interested in looking into this study in more depth.
https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/
Read More About The Pros and Cons Of Using Multi-Timeframe Indicators
HTH
 
Is this a repainting strategy?

I've done some backtests with ToS strategies and the results seem really good, maybe a little too good.
 
Multi-Timeframe True Momentum Oscillator - Two Timeframe version:

Code:
# filename: MR__EZ_TMO_MTF_Fisher_2Agg_
# source: https://usethinkscript.com/d/91-tmo-with-higher-agg-mobius-tsl

# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
#hint: TMO calculates momentum using the DELTA of price. Giving a much better picture of trend, trend reversals and divergence than momentum oscillators using price.

declare lower;

input length = 10; # default -> 14;
def calcLength = 5;
def smoothLength = 3;
input agg = AggregationPeriod.FIVE_MIN;

def o = open(period = agg);
def c = close(period = agg);
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 = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
     Main.AssignValueColor(if Main > Signal
                            then color.GREEN
                            else color.RED);
     Signal.AssignValueColor(if Main > Signal
                            then color.GREEN
                            else color.RED);
     Main.SetLineWeight(3);
     Signal.SetLineWeight(3);
     Signal.HideBubble();
     Signal.HideTitle();


# JQ_FisherTransform_wLabels v02
# assistance provided by AlphaInvestor, amalia, randyr and nube

# v02 9.23.2018 JQ added arrows

input Fisherprice = hl2;
input FisherLength = 10;
input TriggerLineOffset = 1; # Ehler's value of choice is 1
input TriggerLine_Color_Choice = {"magenta", "cyan", "pink", default "gray", "Mustard", "red", "green", "dark_gray", "Pale Yellow", "white"};
input deBug = no;

def maxHigh = Highest(Fisherprice, FisherLength);
def minLow = Lowest(Fisherprice, FisherLength);
def range = maxHigh - minLow;
def value = if IsNaN(Fisherprice)
then Double.NaN
else if IsNaN(range)
then value[1]
else if range == 0
then 0
else 0.66 * ((Fisherprice - minLow) / range - 0.5) + 0.67 * value[1];
def truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value;
def fish = 0.5 * (Log((1 + truncValue) / (1 - truncValue)) + fish[1]);
def FTOneBarBack = fish[TriggerLineOffset];
def FT = fish;

plot FisherBullCross = if FT crosses above FTOneBarBack then lowestall(Main) else Double.NaN;
FisherBullCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
FisherBullCross.SetDefaultColor(Color.UPTICK);

plot FisherBearCross = if FT crosses below FTOneBarBack then highestall(Main) else Double.NaN;
FisherBearCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
FisherBearCross.SetDefaultColor(Color.DOWNTICK);


input length2 = 10; # default -> 14;
def calcLength2 = 5;
def smoothLength2 = 3;
input agg2 = AggregationPeriod.FIFTEEN_MIN;

def o2 = open(period = agg2);
def c2 = close(period = agg2);
def data2 = fold i2 = 0 to length2
           with s2
           do s2 + (if c2 > getValue(o2, i2)
                   then 1
                   else if c2 < getValue(o2, i2)
                        then - 1
                        else 0);
def EMA52 = ExpAverage(data2, calcLength2);
plot Main2 = ExpAverage(EMA52, smoothLength2);
plot Signal2 = ExpAverage(Main2, smoothLength2);
     Main2.AssignValueColor(if Main2 > Signal2
                            then color.UPTICK
                            else color.DOWNTICK);
     Signal2.AssignValueColor(if Main2 > Signal2
                            then color.UPTICK
                            else color.DOWNTICK);
     Signal2.HideBubble();
     Signal2.HideTitle();

addCloud(Main, Signal, color.GREEN, color.RED);
addCloud(Main2, Signal2, color.UPTICK, color.DOWNTICK);

plot ZeroLine = 0;
     ZeroLine.SetDefaultColor(Color.ORANGE);
     ZeroLine.HideBubble();
     ZeroLine.HideTitle();

plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.dark_red);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.dark_green);
os.HideBubble();
os.HideTitle();
addCloud(ob, length, color.dark_red, color.dark_red, no);
addCloud(-length, os, color.dark_green, color.dark_green);

Is there a way to setup a scan that only shows tickers that have 2 active Fisher green reversal, and 2 new green plots on the 5 and 15 min?
 
Anybody wanna help with making a label that shows whether TMO is going up or down for multiple time frames: 5 min, 10 min, hourly, daily, weekly. I have a basic idea of how to do it where i basically relabel every variable for the different aggregations, but im sure there's an easier way to do it using a "Script" function. Any takers?
 
@stocksniper there are at least a dozen TMO scripts referenced in this thread. The script in post#1 upon which this thread is based on has no arrows to be moved. You would need to state what post you are referring to or provide the script for someone to be able to assist.
 
@MerryDay

# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
# 5.15.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.

declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg = AggregationPeriod.Fifteen_min;

def o = open(period = agg);;
def c = close(period = agg);
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 = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.HideBubble();
Signal.HideTitle();
addCloud(Main, Signal, color.green, color.red);
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();

# End Code TMO with Higher Aggregation
 
This TMO indicator as well as the TMO with Higher Aggregation both work really well. But what works especially well, at least for me, is using both at the same time. On 1m charts I'll use both the 1m TMO and the 5m TMO. On 5m I'll use the 5m and the 15m. Entering when both are either green or red has become part of my core strategy.

The only problem with this is it's not always easy to notice the matching colors until it's too late.

Would it be possible to somehow merge both scripts so that a label can displayed and/or an alert can sound when both TMO's are pointing the same way?
 
@Yo Adrian I move your request to this thread because it has various variations of what you are asking. Plug&play what you find, to see what works best for you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
310 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