MACD alert question

J

joshua74133

Member
VIP
i cant seem to code this for some reason. any ideas. ive added a alert when the arrow comes in but its not working

Code:
input fastLength = 3;
input slowLength = 6;
input MACDLength = 8;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;


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);
 
rad14733

rad14733

Well-known member
VIP
Not sure if this is what you're trying to achieve but it's working when I use your code as a lower study on GDX at the moment... I get Dings and TOS Messages... Lots of Dings... Try adding these lines to the bottom of your study... Edit it to display whatever message you prefer... I set it to Alert.ONCE because Alert.TICK was too noisy...

Code:
Alert(Diff crosses above ZeroLine, "Diff Above ZeroLine", Alert.ONCE, Sound.Ding);
Alert(Diff crosses below ZeroLine, "Diff Below ZeroLine", Alert.ONCE, Sound.Ding);
 
J

joshua74133

Member
VIP
here is what i got but the word alert is red
Alert (Diff > ZeroLine, Alert.BAR, Sound.RING);
 
rad14733

rad14733

Well-known member
VIP
here is what i got but the word alert is red
Alert (Diff > ZeroLine, Alert.BAR, Sound.RING);
You are missing the alert text... I don't think it can be omitted...
Code:
Alert (Diff > ZeroLine, "Something or Anything Here, or just empty quotes", Alert.BAR, Sound.RING);

Edited to add: Minimum function parameters are condition and text...
 

Similar threads

Top