Archived: TMO True Momentum Oscillator

Status
Not open for further replies.
Is there a way to make a watchlist column to show the distance between the Main and Signal Lines? So you can sort by closest to farthest apart?
 
Is there a way to setup a watchlist column to sort by the distance between the TMO Main line and TMO Signal line?

I have a watchlist that is my TMO scan results for Green TMO (Main line above Signal line) in the under -10 zone and I want to be able to sort that list by thickest to thinnest .

TMO
https://usethinkscript.com/threads/true-momentum-oscillator-for-thinkorswim.15/
hL1ww4J.png
Is there a way to make a watchlist column to show the distance between the Main and Signal Lines? So you can sort by closest to farthest apart?

@bobknob Test this and verify the results -

Code:
# Watchlist column using TMO ((T)rue (M)omentum (O)scilator) by Mobius, V01.05.2018
# column displays the difference between the main and signal lines when the main line is
# above the signal line and both are below the oversold line.

input length = 14;
input calcLength = 5;
input 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 os = -round(length * .7);
def total = Main > Signal and Signal < os;

plot between = if total then Main - Signal else 0;
between.assignvaluecolor(if total then color.green else color.black);

You can add something like AddLabel(1,round(Main - Signal,2),color.white) to your chart's lower True Momentum Oscillator code to have a label show the difference between the two lines.
 
@bobknob Test this and verify the results -

Code:
# Watchlist column using TMO ((T)rue (M)omentum (O)scilator) by Mobius, V01.05.2018
# column displays the difference between the main and signal lines when the main line is
# above the signal line and both are below the oversold line.

input length = 14;
input calcLength = 5;
input 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 os = -round(length * .7);
def total = Main > Signal and Signal < os;

plot between = if total then Main - Signal else 0;
between.assignvaluecolor(if total then color.green else color.black);

You can add something like AddLabel(1,round(Main - Signal,2),color.white) to your chart's lower True Momentum Oscillator code to have a label show the difference between the two lines.

Okay I got this to work and to do what I wanted using the code blow (I'm sure there's a cleaner version of the "plot between" section but it works and gives me a positive value for green trends and a negative for red).

I also tried adding that bit of label code to the end of my TMO code but it crashed it out "invalid statement AddLabel"

Code:
# Watchlist column using TMO ((T)rue (M)omentum (O)scilator) by Mobius, V01.05.2018
# column displays the difference between the main and signal lines and cloud color.

input length = 14;
input calcLength = 5;
input 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 os = -round(length * .7);
def total = Main > Signal;

plot between = if total then Main - Signal else Main - Signal;
between.assignvaluecolor(if total then color.green else color.yellow);
AssignBackgroundColor(if Main > Signal then color.dark_GREEN else color.dark_RED);
 
Last edited:
Okay I got this to work and to do what I wanted using the code blow (I'm sure there's a cleaner version of the "plot between" section but it works and gives me a positive value for green trends and a negative for red).

I also tried adding that bit of label code to the end of my TMO code but it crashed it out "invalid statement AddLabel"

Code:
# Watchlist column using TMO ((T)rue (M)omentum (O)scilator) by Mobius, V01.05.2018
# column displays the difference between the main and signal lines and cloud color.

input length = 14;
input calcLength = 5;
input 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 os = -round(length * .7);
def total = Main > Signal;

plot between = if total then Main - Signal else Main - Signal;
between.assignvaluecolor(if total then color.green else color.yellow);
AssignBackgroundColor(if Main > Signal then color.dark_GREEN else color.dark_RED);
@bobknob Good job with the modifying the code! As you said, it can be "cleaned up", but it does'nt need much at all. Since you are'nt using the oversold level that line of code can be removed, and the plot can be made a bit more concise. As for the AddLabel error, all it needs is a semicolon at the end. Its free code, so . . . . 😁

Code:
# Watchlist column using TMO ((T)rue (M)omentum (O)scilator) by Mobius, V01.05.2018
# column displays the difference between the main and signal lines and cloud color.

input length = 14;
input calcLength = 5;
input 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 total = Main > Signal;

plot between = Main - Signal;
between.assignvaluecolor(if total then color.green else color.yellow);
AssignBackgroundColor(if total then color.dark_GREEN else color.dark_RED);

Here's a new fancier Label to add to the TMO code. This one should work right out of the box.
AddLabel(1,"Difference = " + round(Main - Signal,2), if Main > Signal then color.dark_green else color.dark_red);
 
@unkownriver
TMO ((T)rue (M)omentum (O)scilator) Scan Scanner
Mobius, with modifications by tomsk, 1.1.2020

Ruby:
# TMO ((T)rue (M)omentum (O)scilator) Scan
# Mobius, with modifications by tomsk, 1.1.2020
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input level = -15;   ##Bullish Scan
#input level = 10;   ##Bearish Scan

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);
plot Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
addchartBubble(close,close,main);
plot sell = main crosses below 10 ;
#hint: Comment out using # below to scan for Bullish or Bearish.  Please note that ## applies to conditional scan with parameters -10 (over sold condition) Bullish Scan) and 10 (over bought condition) Bearish Scan) Default is set to a Bullish TMO Scan without any conditions.

##***Bullish Scan***
plot scan = main crosses above level;
#plot scan = main < level and signal < level and main > signal;
#plot scan = main < main[1] and signal < signal[1];

##***Bearish Scan***

##plot scan = main > level and signal > level and main < signal;
#plot scan = main > main[1] and signal > signal[1];
@MerryDay How do I edit this scanner scan so that it can only scan for momentum that is above 0?
 
@jake438899 Set up your scan as follows:
jGYoLgP.png

This scan returns a lot of results. Could you share how you will use this information?
hfJcVms.png
 
@MerryDay
Sure, I just used it as a confirmation of strength that it going fire in the direction that I want it.
https://prnt.sc/17l76la (Not really sure How to add Image since it a https)

But basically, I'm more a swing trader and my trading is influence a lot by John carter. Never toke his any of his class before just because I can't afford it.

I like to buy a Daily Squeeze (Red Dot) with the Weekly that is in a Squeeze. Once the Daily Fired, Combined with the Weekly, 70% of the time it an explosive move to the upside.. Sometime I would use a lower time frame to get into position early (Trying to find another Squeeze). Then, I have a Triple Squeeze Setup. Also, I like to have the VIX up, If it slowly going up then I avoid getting into long position.

Usually, I have a scan for these setup.
 
@MerryDay

Hi, Merry, I came across a code where you added some labels... I made some slight changes to the labels, but wanted to know about how I could having TOS scan for such things as "Cover Shorts", "Trend Begins," and "Bearish" etc. Is there a way that you could help me so that the following labels can be scanned for in TOS? Here is the code:
Ruby:
input showlabels = yes ;
input paintcandles = no ;
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input ob = 10;
input os = -10;

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);

DefineGlobalColor("CoverShorts", CreateColor(50, 200, 255)) ;
DefineGlobalColor("TrendBEGIN", CreateColor(0, 0, 255)) ;
DefineGlobalColor("Rising", CreateColor(0, 165, 0)) ;
DefineGlobalColor("Overowned", CreateColor(255, 139 ,61)) ;
DefineGlobalColor("TrendEnd", CreateColor(255, 204, 0)) ;
DefineGlobalColor("Falling", CreateColor(225, 0, 0)) ;
DefineGlobalColor("Neutral", CreateColor(204, 204, 204)) ;
AddLabel(showlabels,
if main < os then "CoverShorts " +round(main,0) else
if main > ob then "Overowned " +round(main,0) else
if main crosses above os then "TREND BEGIN!" else
if main crosses below ob then "TREND END!" else
if main < signal then "BEARISH " +round(main,0) else
if main >= main[1] then "RISING " +round(main,0) else
if main < main[1] then "FALLING " +round(main,0) else
"NEUTRAL " +round(main,0),
if main < os then GlobalColor("CoverShorts") else
if main > ob then GlobalColor("Overowned") else
if main crosses above os then GlobalColor("TrendBEGIN") else
if main crosses below ob then GlobalColor("TrendEND") else
if main < signal then GlobalColor("falling") else
if main > main[1] then GlobalColor("rising") else GlobalColor("neutral")) ;

AssignPriceColor(
if !paintcandles then color.CURRENT else
if main < os then GlobalColor("CoverShorts") else
if main > ob then GlobalColor("OVEROWNED") else
if main crosses above os then GlobalColor("TrendBEGIN") else
if main crosses below ob then GlobalColor("TrendEND") else
if main < signal then GlobalColor("falling") else
if main > main[1] then GlobalColor("rising") else GlobalColor("neutral")) ;
# End Code TMO
 
Last edited by a moderator:
TMO Scan Based On Label Conditions
Save the below script as a study. In the TOS scan the parameters are as follows:

for CoverShorts...... ScanTrigger = 1​
for Overowned....... ScanTrigger = 2​
for TREND BEGIN!.. ScanTrigger = 3​
for TREND END!..... ScanTrigger = 4​
for BEARISH......... ScanTrigger = 5​
for RISING............ ScanTrigger = 6​
for FALLING......... ScanTrigger = 7​
for NEUTRAL........ ScanTrigger = 0​

Ruby:
# 
# TMO ((T)rue (M)omentum (O)scilator) Scan
# Mobius, with modifications by tomsk, 1.1.2020
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input ob = 10;
input os = -10;

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);

#ScanTrigger
# for CoverShorts = ScanTrigger = 1
# for Overowned   = ScanTrigger = 2
# for TREND BEGIN!= ScanTrigger = 3
# for TREND END!  = ScanTrigger = 4
# for BEARISH     = ScanTrigger = 5
# for RISING      = ScanTrigger = 6
# for FALLING     = ScanTrigger = 7
# for NEUTRAL     = ScanTrigger = 0

Plot scanTrigger =
if main < os then  1 else
if main > ob then 2 else
if main crosses above os then 3 else
if main crosses below ob then 4 else
if main < signal then 5 else
if main >= main[1] then 6 else
if main < main[1] then 7 else 0 ;
# End Code TMO
 
Hi, Merry, I came across a code where you added some labels... I made some slight changes to the labels, but wanted to know about how I could having TOS scan for such things as "Cover Shorts", "Trend Begins," and "Bearish" etc. Is there a way that you could help me so that the following labels can be scanned for in TOS? Here is the code:
input showlabels = yes ;
input paintcandles = no ;
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input ob = 10;
input os = -10;

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);

DefineGlobalColor("CoverShorts", CreateColor(50, 200, 255)) ;
DefineGlobalColor("TrendBEGIN", CreateColor(0, 0, 255)) ;
DefineGlobalColor("Rising", CreateColor(0, 165, 0)) ;
DefineGlobalColor("Overowned", CreateColor(255, 139 ,61)) ;
DefineGlobalColor("TrendEnd", CreateColor(255, 204, 0)) ;
DefineGlobalColor("Falling", CreateColor(225, 0, 0)) ;
DefineGlobalColor("Neutral", CreateColor(204, 204, 204)) ;
AddLabel(showlabels,
if main < os then "CoverShorts " +round(main,0) else
if main > ob then "Overowned " +round(main,0) else
if main crosses above os then "TREND BEGIN!" else
if main crosses below ob then "TREND END!" else
if main < signal then "BEARISH " +round(main,0) else
if main >= main[1] then "RISING " +round(main,0) else
if main < main[1] then "FALLING " +round(main,0) else
"NEUTRAL " +round(main,0),
if main < os then GlobalColor("CoverShorts") else
if main > ob then GlobalColor("Overowned") else
if main crosses above os then GlobalColor("TrendBEGIN") else
if main crosses below ob then GlobalColor("TrendEND") else
if main < signal then GlobalColor("falling") else
if main > main[1] then GlobalColor("rising") else GlobalColor("neutral")) ;

AssignPriceColor(
if !paintcandles then color.CURRENT else
if main < os then GlobalColor("CoverShorts") else
if main > ob then GlobalColor("OVEROWNED") else
if main crosses above os then GlobalColor("TrendBEGIN") else
if main crosses below ob then GlobalColor("TrendEND") else
if main < signal then GlobalColor("falling") else
if main > main[1] then GlobalColor("rising") else GlobalColor("neutral")) ;
# End Code TMO
I added this script to a watchlist. Can anyone color the backgrounds based on the script? I tried myself but was unsuccessful. TIA
 
The following thinkScript of the true momentum oscillator was created by Mobius.



L5Oru8N.png


thinkScript Code

Rich (BB 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;

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);
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();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);
# End Code TMO

Shareable Link

https://tos.mx/yXqNwi

The following thinkScript of the true momentum oscillator was created by Mobius.



L5Oru8N.png


thinkScript Code

Rich (BB 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;

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);
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();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);
# End Code TMO

Shareable Link

https://tos.mx/yXqNwi
Nice indicator. It would be fun to have a chart where the candlestick colors mimic the color of this True Momentum Oscillator. What would the code be for that?
 
Is the script on the first page/post the current one(indicator) or has there been changes posted elsewhere in the thread?
I haven't the time right now to read through 24 past pages. Thanks.
 
@Tidan Also understand that just because there may be changes or "updates" does not mean that an indicator is better than before. Any "new and updated" version will most likely reflect the personality and trading method of the person that posts that particular version. The original code in post #1 is probably the best - it was written by a math teacher and trader, after all.
 
This the code i´m currently using for TMO, it ´s from the original post with some modification for the signals and i would like to create scanner conditions for both BUYsignal & SELLsignal. Anyone can help me with this?

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 AlertDisplace = 0;

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);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
     Main.AssignValueColor(if Main > Signal
                           then color.green
                           else color.light_red);
     Signal.AssignValueColor(if Main > Signal
                             then color.green
                             else color.light_red);
     Signal.HideBubble();
     Signal.HideTitle();
addCloud(Main, Signal, color.green, color.light_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);

def BUYsignal =Main < OS and Main crosses above Signal and Main <  os;
def SELLsignal = Main > OB and Main crosses below Signal and Main > ob;

# Alerts
Alert(SellSignal[AlertDisplace], " ", Alert.Bar, Sound.ring);
 
@zeek
Copy the code below and paste it directly into the scanner. Hope this helps!
PMNonsc.png

Ruby:
# TMO ((T)rue (M)omentum (O)scilator) **************  scanner only  ****************
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input AlertDisplace = 0;

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);

plot BUYsignal =Main < OS and Main crosses above Signal and Main <  os;
#plot SELLsignal = Main > OB and Main crosses below Signal and Main > ob;
 
Status
Not open for further replies.

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