input price = close;
input length = 200;
input Showlabels = yes;
input ShowPCTlabels = yes;
def AvgExp = ExpAverage(price, length);
def diff = close - AvgExp;
def pctdiff = (diff / AvgExp) * 100;
def waveUP = diff > AvgExp;
def waveDN = diff < AvgExp;
def wavenet = !waveUP and !waveDN;
AddLabel(Showlabels and waveUP, "Price From 200EMA @ " + diff, Color.GREEN);
AddLabel(Showlabels and waveDN, "Price From 200EMA @ " + diff, Color.RED);
AddLabel(Showlabels and wavenet, "Price From 200EMA @ " + diff, Color.YELLOW);
def pctUP = pctdiff > AvgExp;
def pctDN = pctdiff < AvgExp;
def pctnet = !pctUP and !pctDN;
AddLabel(ShowPCTlabels and pctUP, "Percent From 200EMA @ " + pctdiff, Color.GREEN);
AddLabel(ShowPCTlabels and pctDN, "Percent From 200EMA @ " + pctdiff, Color.RED);
AddLabel(ShowPCTlabels and pctnet, "Percent From 200EMA @ " + pctdiff, Color.YELLOW);