Scan for MACD at its highest level


Category:
0
0

I am trying to find stocks that have 52-week high MACD levels.

Editors note: Video link removed. The video was not required to express the context of the question.

If you skip to minute 13 of this video you will see why this scanner should be very helpful.

Marked as spam
Posted by (Questions: 6, Answers: 14)
Asked on July 19, 2017 1:50 am
167 views
0
Private answer

Only need to add a single line of code to accomplish this. Two if you want the option of scanning for both the Histogram and the MACD Value. Here is the full code, taken from the builtin MACD study included with Thinkorswim. The scan must be run on a daily time frame. Screenshots included below showing both modes of operation.

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Diff = Value - Avg;
# use this scan to find 52 week high MACD Histogram
plot scan = Diff > Highest(Diff[1], 252);
# use this scan to find 52 week high MACD Value
#plot scan = Value > Highest(Value[1], 252);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on July 19, 2017 7:58 am
0

Would there be any way to set up a scan to look back at least 4 years in a monthly time frame?
As you mentioned it only works with the daily time frame…

( at July 21, 2017 9:44 pm)
0

No. As stated in previous posts, there is a limit of two years historical data available for scans. This limit applies to daily time frame and higher.

( at July 21, 2017 10:21 pm)
0
Is it possible to create a scan in which the stock’s MACD level is currently sitting at the same level or just below 52-week year MACD level highs? I noticed that if we scan for its highest level we are missing all the profits, on the other hand if we scan for the macd at the same level highs or just below it, we might be able to position ourselves for a major move. Thank you Pete, you truly are great and I appreciate your hard work.
( at July 24, 2017 10:35 pm)
0

Just need to define how that is calculated. ”…at the same level…” that is easy, just use an equal sign. ”…or just below…”, that one needs to be clearly defined. Show me the math you want to use and we can incorporate that.

( at July 25, 2017 7:50 am)
0

lets say 1 percent less than the highest 52-week macd high….

where would the equal sign be, should the > be replaced by = in the same code?

( at July 25, 2017 11:29 am)
0
Private answer

Thank you Mr. Hahn.

Marked as spam
Posted by (Questions: 6, Answers: 14)
Answered on July 19, 2017 8:51 am
0
Private answer

In response to a request to modify the code to account for MACD “near or at” it’s 52 week high. The following code provides this functionality. A very important thing to note is that using the default setting of 1.0 percent will make the signal extremely rare.

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input percentLimit = 1.0;
def factor = 1 - (percentLimit * 0.01);
def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Diff = Value - Avg;
# use this scan to find 52 week high MACD Histogram
plot scan = Diff <= Highest(Diff[1], 252) and Diff >= Highest(Diff[1], 252) * factor;
# use this scan to find 52 week high MACD Value
#plot scan = Value < Highest(Value[1], 252) and Value >= Highest(Value[1], 252) * factor;

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on July 25, 2017 2:49 pm
0

I noticed it is rare indeed because the scanner didn’t find any stocks, I tried deleting the one percent requirement so that the scan would just search for a MACD 52-week equal high but did not work either, I am sure there is a way to code it but I’m just not sure how to.
Let’s pretend this is the MACD and the right hand side is at exactly the same high as in the past, this is
what I am trying to scan for. Hopefully I explained it correctly.
\ / < ~~~~~~~~~~~~~~ scanning for this edge, not over past higher highs. \ / \____ /

( at July 25, 2017 6:31 pm)
0

Eliminating the percentage would actually make it nearly impossible to find a signal. The MACD being exactly the same as a previous value is almost never going to happen. If you want to increase the frequency, keep the percentage filter and increase the percentage value. Start at a very high number, say 50%. Then work your way down until you get just a few results.

( at July 25, 2017 7:02 pm)
0

Thank you for clarifying Pete

( at July 25, 2017 8:49 pm)