```
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);
fastLength.SetDefaultColor(GetColor(9));
slowLength.SetDefaultColor(GetColor(5));
MACDLength.SetDefaultColor(GetColor(8));
fastLength.DefineColor("Up", GetColor(1));
fastLength.DefineColor("Down", GetColor(0));
fastLength.AssignValueColor(if fastLength > fastLength [1] then fastLength.color("Up") else fastLength.color("Down"));
slowLength.DefineColor("Up", GetColor(1));
slowLength.DefineColor("Down", GetColor(0));
slowLength.AssignValueColor(if slowLength > slowLength [1] then slowLength.color("Up") else slowLength.color("Down"));
MACDLength.DefineColor("Up", GetColor(1));
MACDLength.DefineColor("Down", GetColor(0));
MACDLength.AssignValueColor(if MACDLength > MACDLength [1] then MACDLength.color("Up") else MACDLength.color("Down"));
```