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