MACD value line crosses avg line with close above 200 ema


Category:
0
0

hi everyone 

can someone halp me edit this code please ?

i like to get an Alert every time MACDline Crosses Signaline not just above Zeroline ! 

and can i make it Study Alert So when price is above 200Ema i get push notification only for UpSignal (MACDline Crosses Signaline From Below) and vice versa.

#
# TD Ameritrade IP Company, Inc. (c) 2007-2017
#
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Alert(UpSignal == ZeroLine, "Up Arrow Alert", Alert.BAR, Sound.RING);
Alert(DownSignal == ZeroLine, "Down Arrow Alert", Alert.BAR, Sound.RING);

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on May 7, 2020 9:58 pm
288 views
0
I was asking the same thing, but I'm not sure there is a way to script that...Peter? How I understand the MACD is that the Zeroline (the middle line on the histogram), while you may have the MACD lines cross while they are BELOW it, technically once they cross they are now above the zeroline (shown by how when they cross, the histogram goes from green to red or red to green if going down). Even though visually to us we (traders) like it when the MACD is suppressed and low, technically at that point it's above the zeroline. But I agree...i would love a script that would only signal when the MACD is below the line visually, even though technically it's above the zero line (or at the zero line exactly) when it crosses.
( at May 8, 2020 6:33 am)
0
I'm using this code however for MACD signals and 200 SMA going up: MACD()."Value" crosses above MACD()."Avg" AND close > Average(close, 200) and this one for going down: MACD()."Value" crosses below MACD()."Avg" AND close < Average(close, 200)
( at May 8, 2020 6:36 am)
0
Private answer

There is nothing about this code that captures the value line of the MACD crossing the average line of the MACD. There are three plots of the MACD. The Value, Avg and Diff. Please be careful to use the correct names for each plot or nobody will be able to understand what you are requesting. The signals in this code are only capturing when the plot name Diff crosses the zero line.

You can build this using the Condition Wizard and you don't have to understand one thing about writing code. Be sure to watch the entire video on this topic before viewing the screenshots below:

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

Notice each step in the process, very much like the examples you saw in the video. This covers the MACD Value crossing above the MACD Avg while the MACD Value is below the zero line and the close is greater than the 200 period exponential moving average. You can use this for a Study Filter in a scan as well as a Study Alert.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 8, 2020 8:34 am