Archived: TMO True Momentum Oscillator

Status
Not open for further replies.

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

Curious if anyone has the TradeStation Easy Language port of TMO?
Hope someone replies saying yes, but I haven't found one. I am going to try to code it myself sometime this week. Just made the switch from TOS to TradeStation and I wish I had done it sooner. SO much better for systematic traders, and EasyLanguage is as easy as Thinkscript but much more powerful.

Anyway, I'll post the code here for the TS TMO if I'm successful.
 
Got the TMO (including MTF) working in EasyLanguage / Tradestation for anyone interested. To setup multiple time frames in TradeStation see this post: https://futures.io/easylanguage-pro...rame-programming-easylanguage.html#post154004

If you prefer not to have the MTF, just delete everything below {Data2}.
Code:
{TMO ((T)rue (M)omentum (O)scilator) - Universal Edition with Multiple Time Frames
originally created by Mobius, modified by hCaostrader, and ported to EasyLanguage with Multiple Time Frame capability added by TraderKevin
V12.8.2020
TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.}

inputs: 
    Length( 14 ) [
        DisplayName = "Length",
        ToolTip = "Enter the number of bars to be used in the calculation of the TMO."],
    
    calcLength( 5 ) [
        DisplayName = "calcLength",
        ToolTip = "Enter the number of bars to be used in the calculation of the calcLength."],
        
    smoothLength( 3 ) [
        DisplayName = "smoothLength",
        ToolTip = "Enter the number of bars to be used in the calculation of the smoothLength."],
    Cloud(False) [
        DisplayName = "Cloud",
        ToolTip = "True to display cloud, false to disable."];

 variables: 
    x( 0, data1 ),
    normdata(0, data1),
    ema(0, data1),
    main(0, data1),
    signal(0, data1),
    ob(0, data1),
    os(0, data1),
    dat(0, data1),
    y(0, data1),
    intrabarpersist double uptrans(0),
    intrabarpersist double downtrans(0),
    intrabarpersist double span(0, data1),
    gap(0, data1),
    x2( 0, data2 ),
    normdata2(0, data2),
    ema2(0, data2),
    main2(0, data2),
    signal2(0, data2),
    dat2(0, data2),
    y2(0, data2),
    intrabarpersist double uptrans2(0),
    intrabarpersist double downtrans2(0),
    intrabarpersist double span2(0, data2),
    gap2(0, data2);;
    
{Data1}
dat = 0;
                
for x = 1 to Length Begin
if c > c[x] Then y = 1
            else if c < c[x] Then y = -1
                else y = 0;
    dat = dat + y ;
    end;
                
normdata = dat * 100 / length;
ema = XAverage(normdata, calcLength);
main = XAverage(ema, smoothLength);
signal = XAverage(main, smoothLength);
ob = 70;
os = -70;
uptrans = ARGB( 100, 0, 128, 0 );
downtrans = ARGB( 100, 255, 0, 0 );

plot1(main, "Main", iff(main > signal, Green, Red));
plot2(signal, "Signal", iff(main > signal, green, red));
plot3(0, "Zero", Lightgray);
plot4(ob, "OB", Darkred);
plot5(os, "OS", Darkgreen);

span = 0.5 * (main + signal);
gap = main - signal;

if cloud then
    plot6(span, "Cloud", iff(main > signal, uptrans, downtrans), default, iff(gap > 10, 13, 11));

    

{Data2}
dat2 = 0;

                
for x2 = 1 to Length Begin
if c of data2 > c[x2] of data2 Then y2 = 1
            else if c of data2 < c[x2] of data2 Then y2 = -1
                else y2 = 0;
    dat2 = dat2 + y2 ;
    end;
                
normdata2 = dat2 * 100 / length;
ema2 = XAverage(normdata2, calcLength);
main2 = XAverage(ema2, smoothLength);
signal2 = XAverage(main2, smoothLength);


plot7(main2, "Main2", iff(main2 > signal2, darkcyan, Darkmagenta));
plot8(signal2, "Signal2", iff(main2 > signal2, darkcyan, Darkmagenta));

span2 = 0.5 * (main2 + signal2);
gap2 = main2 - signal2;

if cloud then
    plot9(span2, "Cloud", iff(main2 > signal2, uptrans, downtrans), default, iff(gap2 > 10, 13, 11));
 
Got the TMO (including MTF) working in EasyLanguage / Tradestation for anyone interested. To setup multiple time frames in TradeStation see this post: https://futures.io/easylanguage-pro...rame-programming-easylanguage.html#post154004

If you prefer not to have the MTF, just delete everything below {Data2}.
Code:
{TMO ((T)rue (M)omentum (O)scilator) - Universal Edition with Multiple Time Frames
originally created by Mobius, modified by hCaostrader, and ported to EasyLanguage with Multiple Time Frame capability added by TraderKevin
V12.8.2020
TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.}

inputs:
    Length( 14 ) [
        DisplayName = "Length",
        ToolTip = "Enter the number of bars to be used in the calculation of the TMO."],
   
    calcLength( 5 ) [
        DisplayName = "calcLength",
        ToolTip = "Enter the number of bars to be used in the calculation of the calcLength."],
       
    smoothLength( 3 ) [
        DisplayName = "smoothLength",
        ToolTip = "Enter the number of bars to be used in the calculation of the smoothLength."],
    Cloud(False) [
        DisplayName = "Cloud",
        ToolTip = "True to display cloud, false to disable."];

variables:
    x( 0, data1 ),
    normdata(0, data1),
    ema(0, data1),
    main(0, data1),
    signal(0, data1),
    ob(0, data1),
    os(0, data1),
    dat(0, data1),
    y(0, data1),
    intrabarpersist double uptrans(0),
    intrabarpersist double downtrans(0),
    intrabarpersist double span(0, data1),
    gap(0, data1),
    x2( 0, data2 ),
    normdata2(0, data2),
    ema2(0, data2),
    main2(0, data2),
    signal2(0, data2),
    dat2(0, data2),
    y2(0, data2),
    intrabarpersist double uptrans2(0),
    intrabarpersist double downtrans2(0),
    intrabarpersist double span2(0, data2),
    gap2(0, data2);;
   
{Data1}
dat = 0;
               
for x = 1 to Length Begin
if c > c[x] Then y = 1
            else if c < c[x] Then y = -1
                else y = 0;
    dat = dat + y ;
    end;
               
normdata = dat * 100 / length;
ema = XAverage(normdata, calcLength);
main = XAverage(ema, smoothLength);
signal = XAverage(main, smoothLength);
ob = 70;
os = -70;
uptrans = ARGB( 100, 0, 128, 0 );
downtrans = ARGB( 100, 255, 0, 0 );

plot1(main, "Main", iff(main > signal, Green, Red));
plot2(signal, "Signal", iff(main > signal, green, red));
plot3(0, "Zero", Lightgray);
plot4(ob, "OB", Darkred);
plot5(os, "OS", Darkgreen);

span = 0.5 * (main + signal);
gap = main - signal;

if cloud then
    plot6(span, "Cloud", iff(main > signal, uptrans, downtrans), default, iff(gap > 10, 13, 11));

   

{Data2}
dat2 = 0;

               
for x2 = 1 to Length Begin
if c of data2 > c[x2] of data2 Then y2 = 1
            else if c of data2 < c[x2] of data2 Then y2 = -1
                else y2 = 0;
    dat2 = dat2 + y2 ;
    end;
               
normdata2 = dat2 * 100 / length;
ema2 = XAverage(normdata2, calcLength);
main2 = XAverage(ema2, smoothLength);
signal2 = XAverage(main2, smoothLength);


plot7(main2, "Main2", iff(main2 > signal2, darkcyan, Darkmagenta));
plot8(signal2, "Signal2", iff(main2 > signal2, darkcyan, Darkmagenta));

span2 = 0.5 * (main2 + signal2);
gap2 = main2 - signal2;

if cloud then
    plot9(span2, "Cloud", iff(main2 > signal2, uptrans, downtrans), default, iff(gap2 > 10, 13, 11));
Do you have screen shots and do you have this enhance version for TOS?
 
@Branch Thank you for this script. Its spot-on on a 2,5 and 10-minute chart that I use without changing any settings. Hopefull net me some positive results. God belss
 
@TraderKevin Great work! TMO is really similar to the Stochastic Oscillator. The key difference is that it looks at the evaluation timeframe from "the other side". With the Stochastic Oscillator, the "evaluation rectangle" grows in size with the current candle, whereas with TMO, its size is defined by the previous candles. This makes the TMO raw data be fully cranked up for as long as the current candle is a valid breakout candle. Whereas on the Stochastic Oscillator, the scale already adapted to the new size and even within the current candle, the oscillator will retrace.

I think you might be interested in this code snippet for the TMO calculation from my PineScript implementation. Look at how the whole calculation is done very cleanly with the ternary operator. So if EasyLanguage also supports ternary operators, I thought you might want to beautify your code.
Code:
// Calculating
oscl = 0
  
for i = 1 to length
    oscl := oscl + (src > src[i] ? 1 : src < src[i] ? - 1 : 0)

normFactor = 100 / length
oscl := oscl * normFactor

ma = ema(oscl, calcLength)
tmo = ema(ma, smoothLength)
signal = ema(tmo, smoothLength)
 
@Branch any reason you chose 7,5,3 as the settings instead of 14,5,3? Is it for a faster response since you are using tick charts to scalp?
I wanted to shorten the movement to run alongside another indicator I use. I will be sharing next week. By shortening the length it forces me to be in a trade a shorter time. As you know you can always adjust it to your "flavor." Remember: longer periods will lower the frequency of whipsaws but generate delayed positive or negative crossovers. On the other hand, shortening the length will elicit many crossovers that fail to generate significant trend movement. And this is why I use a second indicator to handle that in-between. @ssaeed73 the short answer to your question is Yes. Faster response but I also want to see the longer response. Try using the Spearman for your in-between.
 
Last edited:
I wanted to shorten the movement to run alongside another indicator I use. I will be sharing next week. By shortening the length it forces me to be in a trade a shorter time. As you know you can always adjust it to your "flavor." Remember: longer periods will lower the frequency of whipsaws but generate delayed positive or negative crossovers. On the other hand, shortening the length will elicit many crossovers that fail to generate significant trend movement. And this is why I use a second indicator to handle that in-between.
I'm trying to learn to the scalp, new to the trading plus market being a rollercoaster I like to get in and out. Can't wait for what you have cooked with your next indicator.

Here is my 2-minute chart. Any suggestions and information to make it better will be greatly appreciated. Hope this chart helps others too.
https://tos.mx/uuKxokB
 
@s1111 You have a lot of what I call "noise" going on but that is just my opinion. I like to have readable charts with only "valuable" indicators. I did not see any moving averages on your chart or labels covering those MAs so that you do not have to show them on the chart. I believe those MAs are important. Also, in the near future learn how to use TOS flex grid function so that you can break up your indicators and charts. Your setup forces you to use the 2 min to monitor everything including your indicators and sometimes you may need to have your indicators set at a different time such as a 1 minute on a 2 minute chart to give you a earlier reading/movement. I have learned not to box myself in when monitoring time frames with indicators. You may want to add the VWAP and remove the IchiPho. We can start there.
 
@Branch . Thank you so much for taking your time and reviewing my setup. Yes, I have way too many damn things, too much to watch, and with a lack of trading knowledge. I have removed Ichipho. Added sma50 and vwap. Slowly I will remove most unnessery indicators. Now I have I have 2 min. 5 min and 10 chart setup. Playing with tos flex grid, trying to make it clean so I can actually see lol.
 
@Branch . Thank you so much for taking your time and reviewing my setup. Yes, I have way too many damn things, too much to watch, and with a lack of trading knowledge. I have removed Ichipho. Added sma50 and vwap. Slowly I will remove most unnessery indicators. Now I have I have 2 min. 5 min and 10 chart setup. Playing with tos flex grid, trying to make it clean so I can actually see lol.
I recommend that you draw (sketch) on a piece of paper how you want your screen to look and what information you need it to tell you; similar to a luxury car dashboard. Think if that way. Then start to build it.
 
Does anyone have a mobile friendly version of this indicator?

Code:
#TMO True Momentum Oscilator _Mobius
#Monday, May 14, 2018 8:31 AM

## "##" indicates an addition or alteration by the Archivist
## OneNote Archive Name: TMO True Momentum Oscilator _Mobius
## Archive Section: Momentum
## Suggested Tos Name: TrueMomentumOscillator_Mobius
## Archive Date: 5.14.2018
## Archive Notes:
# Markos changed colors for cloud 01-31-19
## Original Code Follows

# 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.green, color.green, Yes);
AddCloud(data1 = -length, data2 = os, color1 = Color.RED, showBorder = yes);
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);
# End Code TMO
 
@kshires4 The indicator posted on the first page of this thread should work right out of the box.

The modified version you posted above will not work because some of the variables aren't supported by the mobile app.

Wi3jWII.png
 
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
386 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