input AtrAvgLength = 14;
def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY), close(period = aggregationPeriod.DAY), low(period = aggregationPeriod.DAY)), AtrAvgLength);
def TodayHigh = Highest(high(period = aggregationPeriod.DAY), 1);
def TodayLow = Lowest(low(period = aggregationPeriod.DAY), 1);
def DTR = TodayHigh - TodayLow;
def DTRpct = Round((DTR / ATR) * 100, 0);
AddLabel(yes, DTRpct,Color.black);
#EMAS
input Ema1Length = 5;
input Ema2Length = 12;
input Ema3Length = 34;
input Ema4Length = 50;
Def FastEMA1 = ExpAverage(close, Ema1Length);
Def FastEMA2 = ExpAverage(close, Ema2Length);
Def SlowEMA1 = ExpAverage(close, Ema3Length);
Def SlowEMA2 = ExpAverage(close, Ema4Length);
#EMAS BULLISH OR BEARISH
def FastEMABullish = FastEMA1 > FastEMA2;
def SlowEMABullish = SlowEMA1 > SlowEMA2;
def FastEMABearish = FastEMA1 < FastEMA2;
def SlowEMABearish = SlowEMA1 < SlowEMA2;
#EMA BUY SIGNAL
def BothEMASBullish = FastEMABullish and SlowEMABullish;
def BothEMASBearish = FastEMABearish and SlowEMABearish;
assignBackgroundColor(if BothEMASBullish then createcolor (0, 255, 0) else if BothEMASBearish then createcolor (0, 0, 255) else color.black);