Archived: TMO True Momentum Oscillator

Status
Not open for further replies.
I'm using this TMO label that show me some information about the signal, i want to add another detail in my label that tells me when the signal goes ob and os, i try few ideas but every time only show me one, like if the signal is above 0 and above ob only show me one but not both, can some one give me an idea how to write this part?

My label tells me when the signal is rising or falling and if its over 0 or below -0 and what I was trying to add inside the label is that let me know if its above 10 or below -10 too. Something like TMO above 0 and over 10, same for below?

Code:
# TMO Label
def length = 14;
def calcLength = 5;
def smoothLength = 3;

def ob = if isNaN(close) then Double.NAN else round(length * .7);
def os = if isNaN(close) then Double.NAN else -round(length * .7);

def data = fold i = 0 to length with s do s + (if close > getValue(open, i) then 1 else if close < getValue(open, i) then - 1 else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

def riUp = main >= main[1];
def faDn = main < main[1];

AddLabel(yes,  
     if riUp and main and signal < 0 then " TMO Rising Below: " + " -0 " + " " else   
     if riUp and main and signal > 0 then " TMO Rising Above: " + " 0 " + " " else   
     if faDn and main and signal > 0 then " TMO Falling Above " + " 0 " + " " else   
     if faDn and main and signal < 0 then " TMO Falling Below " + " -0 " + " " else " ",   
     if riUp and main and signal < 0 then Color.Dark_GREEN else   
     if riUp and main and signal > 0 then Color.GREEN else   
     if faDn and main and signal > 0 then Color.DARK_RED else   
     if faDn and main and signal < 0 then Color.RED else Color.CURRENT);
 
Last edited by a moderator:

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

Here is what you requested. I am not sure how useful this will be. It requires that the TMO and it's average walk in lock step which doesn't always happen. Might be better to test for main or its signal. Not both.

When testing for multiple conditions: the order that you nest your if statements is vital. Here we test for 10 and -10 first. If satisfied, it gets a 10/-10 label. Otherwise, it moves on to test for the zero condition.

Ruby:
def riUp = main >= main[1];
def faDn = main < main[1];

AddLabel(yes,
     if riUp and main<-10 and signal <-10 then " TMO Rising Below: " + " -10 " + " " else  
     if riUp and main>10 and signal > 10 then " TMO Rising Above: " + " 10 " + " " else  
     if faDn and main>10 and signal >10 then " TMO Falling Below " + " 10 " + " " else  
     if faDn and main<-10 and signal <-10 then " TMO Falling Below " + " -10 " + " " else
 
     if riUp and main<0 and signal < 0 then " TMO Rising Below: " + " -0 " + " " else  
     if riUp and main>0 and signal > 0 then " TMO Rising Above: " + " 0 " + " " else  
     if faDn and main>0 and signal > 0 then " TMO Falling Above " + " 0 " + " " else  
     if faDn and main<0 and signal < 0 then " TMO Falling Below " + " -0 " + " " else " ",  
   
     if riUp and main<-10 and signal <-10 then Color.Dark_GREEN else  
     if riUp and main>10 and signal > 10 then Color.GREEN else  
     if faDn and main>10 and signal > 10 then Color.DARK_RED else  
     if faDn and main<-10 and signal < -10 then Color.RED else
 
     if riUp and main<0 and signal < 0 then Color.Dark_GREEN else  
     if riUp and main>0 and signal > 0 then Color.GREEN else  
     if faDn and main>0 and signal > 0 then Color.DARK_RED else  
     if faDn and main<0 and signal < 0 then Color.RED else Color.CURRENT);
53S6axX.png
 
Here is what you requested. I am not sure how useful this will be. It requires that the TMO and it's average walk in lock step which doesn't always happen. Might be better to test for main or its signal. Not both.

When testing for multiple conditions: the order that you nest your if statements is vital. Here we test for 10 and -10 first. If satisfied, it gets a 10/-10 label. Otherwise, it moves on to test for the zero condition.

Ruby:
def riUp = main >= main[1];
def faDn = main < main[1];

AddLabel(yes,
     if riUp and main<-10 and signal <-10 then " TMO Rising Below: " + " -10 " + " " else 
     if riUp and main>10 and signal > 10 then " TMO Rising Above: " + " 10 " + " " else 
     if faDn and main>10 and signal >10 then " TMO Falling Below " + " 10 " + " " else 
     if faDn and main<-10 and signal <-10 then " TMO Falling Below " + " -10 " + " " else
 
     if riUp and main<0 and signal < 0 then " TMO Rising Below: " + " -0 " + " " else 
     if riUp and main>0 and signal > 0 then " TMO Rising Above: " + " 0 " + " " else 
     if faDn and main>0 and signal > 0 then " TMO Falling Above " + " 0 " + " " else 
     if faDn and main<0 and signal < 0 then " TMO Falling Below " + " -0 " + " " else " ", 
  
     if riUp and main<-10 and signal <-10 then Color.Dark_GREEN else 
     if riUp and main>10 and signal > 10 then Color.GREEN else 
     if faDn and main>10 and signal > 10 then Color.DARK_RED else 
     if faDn and main<-10 and signal < -10 then Color.RED else
 
     if riUp and main<0 and signal < 0 then Color.Dark_GREEN else 
     if riUp and main>0 and signal > 0 then Color.GREEN else 
     if faDn and main>0 and signal > 0 then Color.DARK_RED else 
     if faDn and main<0 and signal < 0 then Color.RED else Color.CURRENT);
53S6axX.png
Here you can have a little more reading from the TMO Indicator in your chart. In case you looking another's indicators and you don't want change charts, here you can read the exact level or moment on the TMO Indicator on your Label. I'm being using this since MarryDay help me with this and normally I don't go to the indicator at all, big thanks MarryDay

Code:
# TMO Label
def lengthtmo = 14;
def calcLength = 5;
def smoothLength = 3;

def data = fold i = 0 to lengthtmo with s do s + (if close > getValue(open, i) then 1 else if close < getValue(open, i) then - 1 else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

def riUp = main >= main[1];
def faDn = main < main[1];

AddLabel(yes,
     if riUp and Main < -10 and signal < -10 then " TMO: " + Round(Main, 2) + " |" + " Rising Below:" + " -10 " + " " else 
     if riUp and Main > 10 and signal > 10 then " TMO: " + Round(Main, 2) + " |" + " Rising Above:" + " 10 " + " " else 
     if faDn and Main > 10 and signal > 10 then " TMO: " + Round(Main, 2) + " |" + " Falling Below:" + " 10 " + " " else 
     if faDn and Main < -10 and signal < -10 then " TMO: " + Round(Main, 2) + " |" + " Falling Below:" + " -10 " + " " else
     if riUp and Main < 0 and signal < 0 then " TMO: " + Round(Main, 2) + " |" + " Rising Below:" + " -0 " + " " else 
     if riUp and Main > 0 and signal > 0 then " TMO: " + Round(Main, 2) + " |" + " Rising Above:" + " 0 " + " " else 
     if faDn and Main > 0 and signal > 0 then " TMO: " + Round(Main, 2) + " |" + " Falling Above:" + " 0 " + " " else 
     if faDn and Main < 0 and signal < 0 then " TMO: " + Round(Main, 2) + " |" + " Falling Below:" + " -0 " + " " else "",   
     if riUp and Main < -10 and signal < -10 then Color.Dark_GREEN else 
     if riUp and Main > 10 and signal > 10 then Color.GREEN else 
     if faDn and Main > 10 and signal > 10 then Color.DARK_RED else 
     if faDn and Main < -10 and signal < -10 then Color.RED else
     if riUp and Main < 0 and signal < 0 then Color.Dark_GREEN else 
     if riUp and Main > 0 and signal > 0 then Color.GREEN else 
     if faDn and Main > 0 and signal > 0 then Color.DARK_RED else 
     if faDn and Main < 0 and signal < 0 then Color.RED else Color.CURRENT);

 
@MerryDay
Hello. Could you share the link to the indicator you mentioned in this post #275 [https://usethinkscript.com/threads/...illator-for-thinkorswim.15/page-14#post-45217 Thank you and Merry X-mas

nN4mmEI.png
That is just a visual representation of a label for the indicator in the 1st post
Alternate coloring isn't necessary when plotting the actual indicator. As the top and bottom of the oscillator is self-evident.
The alternate coloring was created for just the labels and the candles for when the lower study is not present.
 
Last edited:
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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