Archived: TMO True Momentum Oscillator

Status
Not open for further replies.
@tomsk The scan that you mentioned in post #93 and #96 with the -10 instance...does that indicate the polarity change or simply crossing from oversold? Also if you change the instance to 10 from -10 will that scan for a bearish instance from over bought? Where exactly would you put the code from post #123? at the top or bottom of the code? Thanks...


Note that posts #93 and #96 were custom scan code for @tenacity11 and @markos For more details read the context/requests just prior to those posts

# For #123, note that this was a specific type of scan for @switchfire. If you like to implement this, just use the scan code I posted in #93 as a base. Then replace the plot scan statement at the end of the file

Code:
plot scan = main < level and signal < level and main > signal;

with the following statement. Just remember that the scan engine only accepts a single plot statement. Anything more than that, the scan editor will flag as an error. Simple as that

Code:
plot scan = main < main[1] and signal < signal[1];


Thanks man! I'll try it out

Have a blast with that @switchfire Once you get the hang of it, you'll be confident of writing your own scan queries, have fun!
 
Last edited:
@tomsk Thank You! So just in case anyone else is looking for a TMO scan can you please confirm below bullish and bearish scans if I got that right? I kept your initial Bullish Scan from post #93 and I added a Bearish Scan as well...then I also implemented what you suggested in post #126 for regular TMO Bullish and Bearish Scans...

Bullish/Bearish TMO Scan: Default is set to Bullish Scan

Code:
# 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 = -10;   ##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);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

#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 < 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];

# End TMO ((T)rue (M)omentum (O)scilator) Scan
 
@markos The higher aggregation causes it to repaint right? Also what is coloring your bars? I couldn't find the study responsible.
Hi, please read the whole first page. You will see my changes compared to the first post that @BenTen put up. Everything is there in the code.
We must not have the same meaning for repaint,but, what ever the color is, that is what it always will be.
 
Hi, please read the whole first page. You will see my changes compared to the first post that @BenTen put up. Everything is there in the code.
We must not have the same meaning for repaint,but, what ever the color is, that is what it always will be.
So if it closes red it stays red? If so this is amazing. Thanks
 
So if it closes red it stays red? If so this is amazing. Thanks
Your welcome. Just confirm with your eyes that what I say and what you believe are the same thing.
Look at the pictures all the way down page one.
You can go into the editor and change the colors of the weekly to what ever you wish so that they stand out better. ...ok, back to the employees...
 
Last edited:
So if it closes red it stays red? If so this is amazing. Thanks
@YungTraderFromMontana I use this indicator...IF you are using a higher aggregation for example...You are using a 5 min chart but you have your TMO set to 30 min...Then the MAIN and SIGNAL will repaint on TMO indicator when you're looking on a 5 min chart...the last 6 bars will change color...This makes it hard to check your strategy after the market closes and the charts aren't live because of the repaint on higher aggregation. I hope that helps.
 
@switchfire Sure, what would be your condition for buying and selling?

Thanks for the reply Ben,

I'd like to test the crossover on various time frames, and maybe even eventually mix and match, e.g. buy on 30 min green cross and sell on hourly red crossover. For now, just a standard cross for a specific time frame would be a good place to start. What do you think?
 
I just thought about it and realized it's probably not possible to back test on diff time frames. What about a simple cross over? Also, could i add another condition, eg rsi crosses a number or similar.
 
@switchfire Here is a simple crossover buy/sell strategy for you to backtest. You can also take this same concept and apply it to other indicators.

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.
# 01/27/2020 Backtesting code added by BenTen

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

# Backtesting Code
def buy = Main crosses above Signal;
def sell = Main crosses below Signal;

AddOrder(OrderType.BUY_AUTO, condition = buy, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");
AddOrder(OrderType.SELL_AUTO, condition = sell, price = close,100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");
 
@YungTraderFromMontana I use this indicator...IF you are using a higher aggregation for example...You are using a 5 min chart but you have your TMO set to 30 min...Then the MAIN and SIGNAL will repaint on TMO indicator when you're looking on a 5 min chart...the last 6 bars will change color...This makes it hard to check your strategy after the market closes and the charts aren't live because of the repaint on higher aggregation. I hope that helps.
Youse guys are using the wrong definition of repaint. The TMO with even 5 aggs would NOT repaint. It just doesn't. @BenTen time for a board meeting!
 
Draw a circle around the repaint or get off the subject, please.

MGqhyYb.png
 
Markos has it correct. It is not a repaint. A repaint is a drawn plot that then changes in the future. If drawn on the close and a future close causes the plot to change it is a repaint. This is where MTF confuses things. On the five minute chart your 5 min TMO plots on the close so will update with a new bar each 5 min. Meanwhile the 30 min TMO also plots on the close. To see the plot of the 30 min you need to wait for the 30 minutes to pass for the next plot. It is not repainting but simply has not passed the time needed to plot the next point.

Are you saying the 5 min plot is changing when the 30 min plot is printed? Those plots should be independent. If that is occurring possible you have somehow introduced an error into the code you are using.
 
@YungTraderFromMontana I use this indicator...IF you are using a higher aggregation for example...You are using a 5 min chart but you have your TMO set to 30 min...Then the MAIN and SIGNAL will repaint on TMO indicator when you're looking on a 5 min chart...the last 6 bars will change color...This makes it hard to check your strategy after the market closes and the charts aren't live because of the repaint on higher aggregation. I hope that helps.
This actually doesn't apply because instead of waiting you can use the previous bars color.
 
This actually doesn't apply because instead of waiting you can use the previous bars color.
@YungTraderFromMontana IF you're using ANY kind of a SuperTrend such as the CSA @diazlaz is working on you will not be able to tell the previous bar's color unless you set something up that tells you where each bar closed. It makes backtesting by looking at charts useless when doing so during non market hours. That is why personally I don't like to set the higher aggregation too far off from the original timeframe...

On a 3m chart I use a 5 min aggregation. On a 5 min I use a 10 min agg...on a 15 min I use a 20 min. This eliminates the fake outs for the most part that you'll experience during a choppy market. I also use other indicators to confirm entries and exits with the TMO.

I combined the TMO with other trending indicators such as Trend Magic, Heikin Ashi Trend, and SuperTrend by Mobius. As in the pic below...the lower section indicates the current time frame...while the upper section indicates the higher aggregation of the indicators I mentioned above to correspond with the same TMO aggregation. I find such a set up useful for my style trading.

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