DGreenleaf17
New member
Sorry for the confusing title, but essentially, I'm curious, i have a script for color coded stacked EMA's, 8 though 135 and if its positively stacked it goes green, negative is red and black is neutral. I was curious if anyone knows how if per example, the 5m, 15m, 30m, 1hr, 2hr, 4hr are all stacked positively, it would be green and so on, so that way i can only have 1 tab for all time frames under the watchlist, instead of 1 per time frame. I tried finding how to code it myself, i just don't know how to add time frames within the code itself.
This is the code i have at the moment.
This is the code i have at the moment.
Code:
def EMA8 = ExpAverage(close, 8);
def EMA13 = ExpAverage(close, 13);
def EMA21 = ExpAverage(close, 21);
def EMA34 = ExpAverage(close, 34);
def EMA45 = ExpAverage(close, 45);
def EMA90 = ExpAverage(close, 90);
def EMA135 = ExpAverage(close, 135);
def bullish = EMA8 > EMA13 and EMA13 > EMA21 and EMA21 > EMA34 and EMA34 > EMA45 and EMA45 > EMA90 and EMA90 > EMA135;
def bearish = EMA8 < EMA13 and EMA13 < EMA21 and EMA21 < EMA34 and EMA34 < EMA45 and EMA45 < EMA90 and EMA90 < EMA135;
AddLabel(bullish, "Bullish Stacked MAs", color.black);
AddLabel(bearish, "Bearish Stacked MAs", color.black);
AddLabel(!bullish and !bearish, " ", color.black);
AssignBackgroundColor(if bullish then color.green else if bearish then color.red else color.black);