PT with EMA for ip
//Created By Nicholas Beeson for IP on 4/10/2016 power trends study(title="NB_PTIP_WITH_EMA", shorttitle="IP_EMA_NB", overlay=true) src = close, pt = input(title="Toggle PT", type=bool, defval=true) em = input(title="Toggle EMA's", type=bool, defval=true) len1 = input(3, minval=1, title="EMA 3") len2 = input(7, minval=1, title="EMA 7") len3 = input(50, minval=1, title="EMA 50") len4 = input(60, minval=1, title="EMA 60") len5 = input(200, minval=1, title="EMA 200") len6 = input(250, minval=1, title="EMA 250") //EMA ema1 = em ? ema(src, len1):na ema2 = em ? ema(src, len2):na ema3 = em ? ema(src, len3):na ema4 = em ? ema(src, len4):na ema5 = em ? ema(src, len5):na ema6 = em ? ema(src, len6):na //EMA Plots plot(ema1, title="EMA 3", style=line, linewidth=4, color=yellow) plot(ema2, title="EMA 7", style=line, linewidth=4, color=white) plot(ema3, title="EMA 50", style=line, linewidth=4, color=red) plot(ema4, title="EMA 60", style=line, linewidth=1, color=orange) plot(ema5, title="EMA 200", style=line, linewidth=1, color=blue) plot(ema6, title="EMA 250", style=line, linewidth=1, color=purple) //chop length = input(14, title="Chop Length") str = sum(tr,length) ltl = lowest(low <= close[1] ? low : close[1],length) hth = highest(high >= close[1] ? high : close[1],length) height = hth - ltl chop = 100 * (log10(str / height) / log10(length)) // ... powertrendlong = pt and (ema1 > ema2 and ema2 > ema3) and (open > close) and (atr(0) < atr(3)) and (chop <= 60) and (chop >= 40) powertrendshort = pt and (ema1 < ema2 and ema2 < ema3) and (open < close) and (atr(0) < atr(3)) and (chop <= 60) and (chop >= 40) //shapes plotshape(powertrendlong, color=lime, offset=0, style=shape.triangleup, location=location.bottom) plotshape(powertrendshort, color=red, style=shape.triangledown, location=location.bottom)