declare lower;
input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
def higherFast = Value > Value[1];
def lowerFast = Value < Value[1];
def higherSlow = Avg > Avg[1];
def lowerSlow = Avg < Avg[1];
plot ZeroLine = 0;
Avg.SetDefaultColor(GetColor(8));
ZeroLine.SetDefaultColor(Color.GRAY);
Value.SetDefaultColor(GetColor(1));
Value.SetPaintingStrategy(PaintingStrategy.LINE);
Value.AssignValueColor(if HigherFast then Color.GREEN else if LowerFast then Color.RED else Color.CYAN);
Value.SetLineWeight(3);
Avg.SetDefaultColor(GetColor(1));
Avg.SetPaintingStrategy(PaintingStrategy.LINE);
Avg.AssignValueColor(if higherSlow then Color.DARK_GREEN else if lowerSlow then Color.DARK_RED else Color.CYAN);
Avg.SetLineWeight(3);
lower;
input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
def higherFast = Value > Value[1];
def lowerFast = Value < Value[1];
def higherSlow = Avg > Avg[1];
def lowerSlow = Avg < Avg[1];
plot ZeroLine = 0;
Avg.SetDefaultColor(GetColor(8));