Create a Scan Based on Multiple Time Frame MACD
This is just a quick article (no video). I received several requests from viewers to demonstrate how to create a custom scan based on the Multi Time-Frame MACD indicator. This MTF MACD indicator is available free via the link embedded in the video located HERE, in a post called Thinkorswim MTF MACD Indicator. You will not need the indicator to build this scan, but be sure to go get it so you can plot it on your charts.
One more thing before we jump right in. If you are not familiar with building custom scans in the Thinkorswim platform, be sure to check out these posts to get up to speed: Thinkorswim Custom Scan Stochastic MACD, Thinkorswim Scan TTM Squeeze Histogram, Thinkorswim Scan MACD RSI Part Two. Everything presented here assumes you’ve already viewed at least one of these videos. So if you feel lost… take the few minutes to watch them and get up to speed.
Ok, here it is. As long as you’ve seen the previous videos, I can show you how to build this scan in two screen shots.
This first screen shot is the Scan tab on the Thinkorswim platform. It shows I’ve added three custom study filters. These are added by pressing the button titled “Add Study Filter”. Make sure you set each of the three to your desired time frame. In this case I’ve got mine set to Monthly, Weekly, and Daily. In the next step, you need to click the pencil icon for each of the three studies. The pencil icon opens up the code editing dialog box. I will provide the code here in this post. Scroll down to the next screen shot.
Ok, here is the code dialog box. I’ve clicked to select the tab titled “thinkscript Editor”. Just copy the code from this post into this screen on your platform. Notice the annotations in this screenshot indicate you can flip this from long to short by moving the “#’ symbol. Scroll down for the code to copy into your platform.
There are two DIFFERENT blocks of code here. This first one is to be placed into the two higher time frames. So for this example, I would have this first code block pasted into my Monthly and Weekly time frames.
input fastLength = 12; input slowLength = 26; input MACDLength = 9; input averageType = AverageType.EXPONENTIAL; def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff; plot scan = Diff > Diff; # OR #plot scan = Diff < Diff;
This second code block is to be pasted into the lowest time frame. In this example, I have this code pasted into my Daily time frame.
input fastLength = 12; input slowLength = 26; input MACDLength = 9; input averageType = AverageType.EXPONENTIAL; def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff; plot scan = Diff >= Diff; # OR #plot scan = Diff <= Diff;
Don’t go anywhere yet. Here are some important tips:
Ok, that’s it. You’re done. Be sure to save the scan before you close the platform or it will be lost and you’ll have to rebuild it. Please note the code for this scan will ensure your higher time frames have at least one candle closed in the desired direction. This is important as it will remove any false signals (as are present in the current version of the MTF MACD Indicator). An updated indicator will be published in the near future. The other thing to note is the code for the lowest time frame is designed to pick only the very first signal in a series. So this scan is not going to pick up signals from 2-3 or more days ago. It’s going to pick up current signals only. So be sure to run it every day (if you are using the time frames displayed here).
Would you like to learn how to master the custom scan tools on Thinkorswim?
Click here: Thinkorswim Scans Beginner to Advanced
Learn how to build custom scans without writing any code: Thinkorswim Condition Wizard
Could a scan be created similar to this one but to 5min, 30min,1,2,4,hour, and DAY
Yes, just change the time frames on the various study filters. Add and remove study filters as needed. Did you read the article prior to posting this question? The reason I ask is that after watching this video your question should have already been answered.
Hi Pete, Thanks for the instruction. How can you make those studies appear in the scan result as columns? (right now they do not show up when trying to customize the scan result columns)
Like this: https://pbs.twimg.com/media/EaHkI_mUMAAGYla?format=jpg&name=large
The columns displayed in the results section of a scan can be modified just the same as any watchlist. However this video did not included any code for custom watchlist columns.
great study! works perfect on the chart. how can this be turned into a scanner as well so we can scan to see which stocks have all 3 times frames the same (when all 3 are green or all 3 are red)?
Um…. that is precisely what this article describes how to do???
A small question I want to know how to use this scan to get stock where in weekly or daily chart it will be just 1-2 bars before the MACD crossover. Now this scan is showing the stock after the MACD crossover I want stock scan just before the crossover.
“just before the crossover”. How exactly do you define that? Because 1-2 bars before the crossover, there is no crossover. It is impossible to read the future.
this scan result gives me the stocks list that don’t show “green” signal in chart as per MTF MACD study – https://www.hahn-tech.com/thinkorswim-mtf-macd-indicator. What am I missing?
Without any other details it is impossible to know “what you are missing”. There are many different settings you can adjust and any one of them may lead to inaccurate results. But the first you should do is make sure you get the most current version of the MTF MACD chart study. The scan is designed to match the second version of the MTF MACD I published. Which is located here: https://www.hahn-tech.com/thinkorswim-strategy-guide-mtf/
Pete, can you show me how to create a display that extracted scan data to show number of stocks in percentage above 50EMA, 100EMA, 200EMA? So can help to tell how strong or weak is the market. Thanks
It will not be possible to assist you in this matter through the comment section of a video. I suggest you post this request in the Q&A forum. We have a topic set up specifically for stock scanners: https://www.hahn-tech.com/ans/cat/scans/
I am playing with this and trying to create a scan on an hourly basis. I find it is an early indicator for options and buying stocks before it shows on the daily. I am wanting 13/30/200 hourly and then look for crosses above and below the 200. Any thoughts?
Nope, I actually have no clue what you are requesting here. The context here is the MTF MACD study. Your question seems to be related to a series of 3 moving averages. If that is the case then this is the wrong place to enter this request. Try our Q&A forum.
I am a bit confused on what the MTF scans for? Today’s scan(2-17-17) pulled up AAPL for the first one. It has neither a red or green dot. I set up my scan the exact way you have posted except for the MACD, I like 8,17,9. Other than that identical. Can you tell me what I did wrong? Is there a way to scan for red/green dots on the histogram? I also have the second version of the indicator as well, it seems the first version gives much faster signals.
Also, The MACD stochastics scan, I’ve set it up like you did in the video and it works great. I tried reversing what I thought was needed to pull up the short trades but had no luck. Any tips on what I should switch to pull up the opposite for short trades? Thanks for your help.
I’ll be able to provide much more detailed response if you post your question in our Q&A forum. As for your question about getting the results of the MTF MACD scan to match the indicator, be sure you are comparing it to version two and not the original. Version two is located here: Thinkorswim Strategy Guide MTF
I like the Multiple time frame approach and I am seeing it is pretty accurate for stocks (I added a few more indicators). I am applying a similar strategy to Futures. So lets take for example /CL with 133 tick, 233 tick, 1 min and 2 min. So to make it simple, when the SMA Crosses over the EMA and there is a confluence over all 4 charts, how can I get a SINGLE ALERT. (I dont mind keeping all the charts open in detached windows). Currently I am able to get 4 alerts (one for each chart).
Thanks and Happy Holidays
Unfortunately the 133 and 233 tick time frames are not supported for scans or multiple time frame studies. 1 min is the lowest time frame supported.
Thats cool. If it were just time frames(1min and 2 mins) would I be able to get a single alert?
We could definitely provide more assistance if this were posted to the Q&A forum. So it sounds like y0u would like a chart based study using 4 time frames that would give you audible and visual alerts while the chart is open. If that is the case, then the solution is a bit more complex than we could provide in the Q&A forum. You should consider submitting this as a custom thinnkscript project using the contact form at the bottom of the “About” page.