input price = close;
input length1 = 8;
input length2 = 21;
input length3 = 34;
input length4 = 55;
input length5 = 89;
input displace = 0;
input showBreakoutSignals = no;
plot EMA8 = ExpAverage(price[-displace], length1);
plot EMA21 = ExpAverage(price[-displace], length2);
plot EMA34 = ExpAverage(price[-displace], length3);
plot EMA55 = ExpAverage(price[-displace], length4);
plot EMA89 = ExpAverage(price[-displace], length5);
EMA8.SetDefaultColor(GetColor(9));
EMA21.SetDefaultColor(GetColor(9));
EMA34.SetDefaultColor(GetColor(9));
EMA55.SetDefaultColor(GetColor(9));
EMA89.SetDefaultColor(GetColor(9));
EMA8.hide();
EMA34.hide();
EMA55.hide();
EMA89.hide();
#stacked EMA's
def trend = (if (EMA8 > EMA21 and EMA21 > EMA34 and EMA34 > EMA55 and EMA55 > EMA89) then 1 else
if (EMA8 < EMA21 and EMA21 < EMA34 and EMA34 < EMA55 and EMA55 < EMA89) then 3 else 0);
EMA8.AssignValueColor (if trend == 3 then color.red else if trend == 1 then color.green else color.current);
EMA21.AssignValueColor (if trend == 3 then color.red else if trend == 1 then color.green else color.yellow);
EMA34.AssignValueColor (if trend == 3 then color.red else if trend == 1 then color.green else color.current);
EMA55.AssignValueColor (if trend == 3 then color.red else if trend == 1 then color.green else color.current);
EMA89.AssignValueColor (if trend == 3 then color.red else if trend == 1 then color.green else color.current);
AddCloud( EMA8, EMA21, Color.Green, Color.Red );
AddCloud( EMA21, EMA34, Color.Green, Color.Red );
AddCloud( EMA34, EMA55, Color.Green, Color.Red );
AddCloud( EMA55, EMA89, Color.Green, Color.red );