#Here is a version that I created. It incorporates 2 additional time frames. It is important to adjust the "LengthLT" and "LengthMT" in conjunction with the time frame that you are using otherwise the coloring will not be correct. In other words. The following is setup for a daily chart and a 3 day and weekly MACD shown as well. But if you wanted to use it with say a one minute then a 5 minute midterm chart and a 15 minute long term then set the "LengthLT" to 15, and the "LengthMT" to 5. It is all about taking the LengthLT and LengthMT and dividing them by chart that you are using. If the number comes to a fraction like using a 2 minute chart with a 5 minute midterm and a 15 minute longterm. Then set your LengthMT to 3 instead of 2.5, and your LengthLT to 8.
declare lower;
input aggregationPeriodLT = AggregationPeriod.Week; #(period = aggregationPeriod)
input LengthLT =5.0;
def fastLengthLT = 12;
def slowLengthLT = 26;
def MACDLengthLT = 9;
def ValueLT = MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodLT), fastLengthLT) - MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodLT), slowLengthLT);
def AvgLT = MovingAverage(AverageType.EXPONENTIAL, ValueLT, MACDLengthLT);
Plot DiffLT = ValueLT - AvgLT;
DiffLT.SetDefaultColor(GetColor(5));
DiffLT.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
DiffLT.SetLineWeight(5);
DiffLT.DefineColor("Positive and Up", Color.Cyan);
DiffLT.DefineColor("Positive and Down", Color.Blue);
DiffLT.DefineColor("Negative and Down", Color.RED);
DiffLT.DefineColor("Negative and Up", Color.Yellow);
DiffLT.AssignValueColor(if DiffLT >= 0 then if DiffLT > DiffLT[LengthLT] then DiffLT.color("Positive and Up") else DiffLT.color("Positive and Down") else if DiffLT < DiffLT[LengthLT] then DiffLT.color("Negative and Down") else DiffLT.color("Negative and Up")); #
AddLabel(yes, "LT", if DiffLT >= 0 then if DiffLT > DiffLT[LengthLT] then DiffLT.color("Positive and Up") else DiffLT.color("Positive and Down") else if DiffLT < DiffLT[LengthLT] then DiffLT.color("Negative and Down") else DiffLT.color("Negative and Up"));
input aggregationPeriodMT = AggregationPeriod.Three_Days;
input LengthMT =3.0;
def fastLengthMT = 12;
def slowLengthMT = 26;
def MACDLengthMT = 9;
plot ValueMT = MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodMT), fastLengthMT) - MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodMT), slowLengthMT);
plot AvgMT = MovingAverage(AverageType.EXPONENTIAL, ValueMT, MACDLengthMT);
AvgMT.DefineColor("Up", Color.WHITE);
AvgMT.DefineColor("Down", Color.PLUM);
AvgMT.AssignValueColor(if AvgMT > AvgMT[LengthMT] then AvgMT.Color("Up") else AvgMT.Color("Down"));
AvgMT.SetLineWeight(2);
AvgMT.Hide();
ValueMT.DefineColor("Up", Color.GREEN);
ValueMT.DefineColor("Down", Color.DARK_RED);
ValueMT.AssignValueColor(if ValueMT > ValueMT[LengthMT] then ValueMT.Color("Up") else ValueMT.Color("Down"));
ValueMT.SetLineWeight(3);
ValueMT.Hide();
Plot DiffMT = ValueMT - AvgMT;
DiffMT.SetDefaultColor(GetColor(5));
DiffMT.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DiffMT.SetLineWeight(3);
DiffMT.DefineColor("Positive and Up", Color.Cyan);
DiffMT.DefineColor("Positive and Down", Color.Blue);
DiffMT.DefineColor("Negative and Down", Color.RED);
DiffMT.DefineColor("Negative and Up", Color.Yellow);
DiffMT.AssignValueColor(if DiffMT >= 0 then if DiffMT > DiffMT[LengthMT] then DiffMT.color("Positive and Up") else DiffMT.color("Positive and Down") else if DiffMT < DiffMT[LengthMT] then DiffMT.color("Negative and Down") else DiffMT.color("Negative and Up"));
AddLabel(yes, "MT", if DiffMT >= 0 then if DiffMT > DiffMT[LengthMT] then DiffMT.color("Positive and Up") else DiffMT.color("Positive and Down") else if DiffMT < DiffMT[LengthMT] then DiffMT.color("Negative and Down") else DiffMT.color("Negative and Up"));
plot ZeroLine3 = 0;
ZeroLine3.SetDefaultColor(Color.Pink);
ZeroLine3.HideTitle();
def fastLengthCONFIRMATION = 3;
def slowLengthCONFIRMATION = 10;
def MACDLengthCONFIRMATION = 15;
#def showBreakoutSignals = no;
plot ValueCONFIRMATION = MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodMT), fastLengthCONFIRMATION) - MovingAverage(AverageType.EXPONENTIAL, close (period = aggregationPeriodMT), slowLengthCONFIRMATION);
plot AvgCONFIRMATION = MovingAverage(AverageType.EXPONENTIAL, ValueCONFIRMATION, MACDLengthCONFIRMATION);
AvgCONFIRMATION.DefineColor("Up", Color.WHITE);
AvgCONFIRMATION.DefineColor("Down", Color.PLUM);
AvgCONFIRMATION.AssignValueColor(if AvgCONFIRMATION > AvgCONFIRMATION[LengthMT] then AvgCONFIRMATION.Color("Up") else AvgCONFIRMATION.Color("Down"));
AvgCONFIRMATION.SetLineWeight(2);
AvgCONFIRMATION.Hide();
ValueCONFIRMATION.DefineColor("Up", Color.GREEN);
ValueCONFIRMATION.DefineColor("Down", Color.DARK_RED);
ValueCONFIRMATION.AssignValueColor(if ValueCONFIRMATION > ValueCONFIRMATION[LengthMT] then ValueCONFIRMATION.Color("Up") else ValueCONFIRMATION.Color("Down"));
ValueCONFIRMATION.SetLineWeight(3);
ValueCONFIRMATION.Hide();
def fast1 = 12;
def slow1 = 26;
def MACD1 = 9;
def ValueST = MovingAverage(AverageType.EXPONENTIAL, close, fast1) - MovingAverage(AverageType.EXPONENTIAL, close, slow1);
def AvgST = MovingAverage(AverageType.EXPONENTIAL, ValueST, MACD1);
Plot DiffST = ValueST - AvgST;
DiffST.SetDefaultColor(GetColor(5));
DiffST.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
DiffST.SetLineWeight(5);
DiffST.DefineColor("Positive and Up", Color.Cyan);
DiffST.DefineColor("Positive and Down", Color.Blue);
DiffST.DefineColor("Negative and Down", Color.RED);
DiffST.DefineColor("Negative and Up", Color.Yellow);
DiffST.AssignValueColor(if DiffST >= 0 then if DiffST > DiffST[1] then DiffST.color("Positive and Up") else DiffST.color("Positive and Down") else if DiffST < DiffST[1] then DiffST.color("Negative and Down") else DiffST.color("Negative and Up"));
DiffST.Hide();
AddLabel(yes, "ST", if DiffST >= 0 then if DiffST > DiffST[1] then DiffST.color("Positive and Up") else DiffST.color("Positive and Down") else if DiffST < DiffST[1] then DiffST.color("Negative and Down") else DiffST.color("Negative and Up"));