How to find a shrinking MACD divergence between days.


Category:
0
0

Hello everyone.  What I’m trying to do is find where the value of the MACD difference was greater yesterday then today.  Below is something I’ve used to find where the value is less than the average, I just want to find the same scenario where yesterday’s difference might be 3 and today’s is 2.  I saw this post but I’m not sure how to retro fit it.

https://www.hahn-tech.com/ans/scan-for-three-consecutive-days-of-two-percent-daily-gain/#

 

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input choice = {default “Diff”,”Value”, “Average”};
input choice2 = {default “Greater Than”, “Less Than”, “Equal to”};

def Value = MovingAverage(averageType, close, fastLength) – MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Diff = Value – Avg;

plot scan1;
scan1 = Value < Avg;

Attachments:
Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on September 24, 2019 3:37 am
141 views
0
Private answer

Those two plots of the MACD that you circled in your screenshot. Those are the exact values used to compute the histogram of the MACD. So in reality what you are trying to measure is the distance of the MACD Histogram from the zero line.

def shrinkingMACD = (diff < 0 and diff > diff[1]) or (diff > 0 and diff < diff[1]);

The histogram of the MACD is a variable named "diff". So we just check if it is above or below zero. Then check if the current histogram bar is closer to the zero line than the previous histogram bar.

Now that you understand this, you can create this scan very simply by using the Condition Wizard and not have to write any code at all.

https://www.hahn-tech.com/thinkorswim-condition-wizard/

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 24, 2019 9:36 am