What I promised. See if that is helpful for you. I just add one for each time frame needed.
#MACD Histogram Cross
#Justin Turner
Declare Upper;
input time_frame = AggregationPeriod.DAY;
def lookback = 1;
def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
def averageType = AverageType.EXPONENTIAL;
def showBreakoutSignals = no;
def time_select = (close(period = time_frame));
def value = MovingAverage(averageType, time_select, fastLength) - MovingAverage(averageType,time_select, slowLength);
def avg = MovingAverage(averageType, Value, MACDLength);
def bull_cross = value crosses above avg;
def bear_cross = value crosses below avg;
def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);
AddLabel (yes,
if Time_Frame == aggregationPeriod.YEAR then "Yr-"
else if
Time_Frame == aggregationPeriod.QUARTER then "Qtr-"
else if
Time_Frame == aggregationPeriod.MONTH then "Mo-"
else if
Time_Frame == aggregationPeriod.WEEK then "Wk-"
else if
Time_Frame == aggregationPeriod.FOUR_DAYS then "4D-"
else if
Time_Frame == aggregationPeriod.THREE_DAYS then "3D-"
else if
Time_Frame == aggregationPeriod.TWO_DAYS then "2D-"
else if
Time_Frame == aggregationPeriod.DAY then "D-"
else if
Time_Frame == aggregationPeriod.FOUR_HOURS then "4H-"
else if
Time_Frame == aggregationPeriod.TWO_HOURS then "2H-"
else if
Time_Frame == aggregationPeriod.HOUR then "1H-"
else if
Time_Frame == aggregationPeriod.THIRTY_MIN then "30m-"
else if
Time_Frame == aggregationPeriod.TWENTY_MIN then "20m-"
else if
Time_Frame == aggregationPeriod.FIFTEEN_MIN then "15m-"
else if
Time_Frame == aggregationPeriod.TEN_MIN then "10m-"
else if
Time_Frame == aggregationPeriod.FIVE_MIN then "5m-"
else if
Time_Frame == aggregationPeriod.FOUR_MIN then "4m-"
else if
Time_Frame == aggregationPeriod.THREE_MIN then "3m-"
else if
Time_Frame == aggregationPeriod.TWO_MIN then "2m-"
else if
Time_Frame == aggregationPeriod.MIN then "1m-"
else "-",
if bull_lookback then createcolor (0,204, 0)
else if
bear_lookback then createcolor (204, 0, 0)
else if
bull_lookback within 2 bars then createcolor (0, 153, 0)
else if
bear_lookback within 2 bars then createcolor (153, 0, 0)
else
color.white);
AddLabel (yes,
if
bull_lookback then "MACD Bull X"
else if
bear_lookback then "MACD Bear X"
else if
bull_lookback within 2 bars then "MACD Bull XX"
else if bear_lookback within 2 bars then "MACD Bear XX"
else "MACD",
if bull_lookback then createcolor (0,204, 0)
else if
bear_lookback then createcolor (204, 0, 0)
else if
bull_lookback within 2 bars then createcolor (0, 153, 0)
else if
bear_lookback within 2 bars then createcolor (153, 0, 0)
else
color.white);