//YAYIMI NUMAN OZDEMIR //Modified on 5-5-14 for 4apprentice08 with Optional BarColor based on Price Crossing MA #1, or #2 //Modified on 7-25-2014 to Add in Tilson T3 //Plots The Majority of Moving Averages //Defaults to Current Chart Time Frame --- But Can Be Changed to Higher Or Lower Time Frames //2nd MA Capability with Show Crosses Feature study(title="CM_Ultimate_MA_MTF_V2", shorttitle="CM_Ultimate_MA_MTF_V2", overlay=true) //inputs src = close useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="D") len = input(20, title="Moving Average Length - LookBack Period") //periodT3 = input(defval=7, title="Tilson T3 Period", minval=1) factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0) atype = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3") spc=input(false, title="Show Price Crossing 1st Mov Avg - Highlight Bar?") cc = input(true,title="Change Color Based On Direction?") smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No Smoothing") doma2 = input(false, title="Optional 2nd Moving Average") spc2=input(false, title="Show Price Crossing 2nd Mov Avg?") len2 = input(50, title="Moving Average Length - Optional 2nd MA") sfactorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0) atype2 = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3") cc2 = input(true,title="Change Color Based On Direction 2nd MA?") warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***") warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***") sd = input(false, title="Show Dots on Cross of Both MA's")
res = useCurrentRes ? period : resCustom //hull ma definition hullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len))) //TEMA definition ema1 = ema(src, len) ema2 = ema(ema1, len) ema3 = ema(ema2, len) tema = 3 * (ema1 - ema2) + ema3
//Formula for Price Crossing Moving Average #1 cr_up = open < out1 and close > out1 cr_Down = open > out1 and close < out1 //Formula for Price Crossing Moving Average #2 cr_up2 = open < out2 and close > out2 cr_Down2 = open > out2 and close < out2 //barcolor Criteria for Price Crossing Moving Average #1 iscrossUp() => cr_up iscrossDown() => cr_Down //barcolor Criteria for Price Crossing Moving Average #2 iscrossUp2() => cr_up2 iscrossDown2() => cr_Down2