CM_Ultimate_MA_MTF_V2 - Added Tilson T3

Defaults to Current Timeframe on Chart.
Ability to Plot 2nd Moving Average.
Ability to set Moving Averages to Custom Chart TimeFrame. Example Daily Ma on 60 Minute chart. Many Different Options from Weekly to 1 Minute.
Ability to Plot Cross where Moving Averages Cross (If using 2nd Moving Average).
Ability to Plot Highlight Bars when Price Crosses 1st Moving Average, or 2nd MA.

Moving Averages Supported in Inputs Tab
SMA - Simple Moving Average
EMA - Exponential Moving Average
WMA - Weighted Moving Average
HullMA - Hull Moving Average
VWMA - Volume Weighted Moving Average
RMA - Moving Average used in RSI - Similar to EMA
TEMA - Triple Exponential Moving Average
Tilson T3 - Tilson T3 Moving Average
Favori Komutlardan Çıkart Favori Komutlara Ekle
//Created by user ChrisMoody 4-24-2014...Updated 7/28/2014 added Tilson T3
//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)
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

//Tilson T3
factor = factorT3 *.10
gd(src, len, factor) => ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor 
t3(src, len, factor) => gd(gd(gd(src, len, factor), len, factor), len, factor) 
tilT3 = t3(src, len, factor) 

avg = atype == 1 ? sma(src,len) : atype == 2 ? ema(src,len) : atype == 3 ? wma(src,len) : atype == 4 ? hullma : atype == 5 ? vwma(src, len) : atype == 6 ? rma(src,len) : atype == 7 ? 3 * (ema1 - ema2) + ema3 : tilT3
//2nd Ma - hull ma definition
hullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2)))
//2nd MA TEMA definition
sema1 = ema(src, len2)
sema2 = ema(sema1, len2)
sema3 = ema(sema2, len2)
stema = 3 * (sema1 - sema2) + sema3

//2nd MA Tilson T3
sfactor = sfactorT3 *.10
sgd(src, len2, sfactor) => ema(src, len2) * (1 + sfactor) - ema(ema(src, len2), len2) * sfactor 
st3(src, len2, sfactor) => sgd(sgd(gd(src, len2, sfactor), len2, sfactor), len2, sfactor) 
stilT3 = st3(src, len2, sfactor) 

avg2 = atype2 == 1 ? sma(src,len2) : atype2 == 2 ? ema(src,len2) : atype2 == 3 ? wma(src,len2) : atype2 == 4 ? hullma2 : atype2 == 5 ? vwma(src, len2) : atype2 == 6 ? rma(src,len2) : atype2 == 7 ? 3 * (ema1 - ema2) + ema3 : stilT3

out = avg 
out_two = avg2

out1 = security(tickerid, res, out)
out2 = security(tickerid, res, out_two)

//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

ma_up = out1 >= out1[smoothe]
ma_down = out1 < out1[smoothe]

col = cc ? ma_up ? lime : ma_down ? red : aqua : aqua
col2 = cc2 ? ma_up ? lime : ma_down ? red : aqua : white

circleYPosition = out2

plot(out1, title="Multi-Timeframe Moving Avg", style=line, linewidth=4, color = col)
plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=circles, linewidth=4, color=col2)
plot(sd and cross(out1, out2) ? circleYPosition : na,style=cross, linewidth=15, color=aqua)
//barcolor Plot for Price Crossing Moving Average #1
barcolor(spc and iscrossUp() ? (iscrossUp() ? yellow : na) : na)
barcolor(spc and iscrossDown() ? (iscrossDown() ? yellow : na) : na)
//barcolor Plot for Price Crossing Moving Average #2
barcolor(spc2 and iscrossUp2() ? (iscrossUp2() ? yellow : na) : na)
barcolor(spc2 and iscrossDown2() ? (iscrossDown2() ? yellow : na) : na)


the MA cross (2 MA) only triggers at close
the single MA (ma_up/down) can trigger in the middle of a bar but has so many fake alerts, specially with low "smoothe" input value
also the the MA cross doesn't trigger at each bar close , only when there is a change, just like having ma_up as crossover(out1,out1)
Cevap Gönder
@guz12, correction : crossover(out1,out1(smoothe)) with brakets instead of () for smoothe
Cevap Gönder
Sorry it was a mistake apparently the alert / change can trigger at any moment as the "close" parameter is the instant value in an ongoing period and is the close of the bar for a complete period. So if there is a huge change it will trigger in the middle of the bar thankfully.
Cevap Gönder
for alerts see message under:

could be good to change the atype2 parameter in the second MA to atype to avoid changing atype and atype2 that don't need to be different
apparently (not investment advice) but the most in use len and len2 are 12 and 26 like ine the MACD indicator script
also it is good to change the "linewidth" parameter to make a clear difference between the 2 MA lines
Cevap Gönder
lines to put before plotting:
-> set all the true / false inputs to "true" value

alertcondition(crossover(out1,out2),"Cross_LONG","Go LONG following MA Cross")
alertcondition(crossunder(out1,out2),"Cross_SHORT","Go SHORT following MA Cross")
alertcondition(ma_up,"Single_MA_LONG","Go LONG following Single MA")
alertcondition(ma_down,"Single_MA_SHORT","Go SHORT following Single MA")


alertcondition(cross_up,"Cross_LONG","Go LONG following MA Cross")
alertcondition(cross_down,"Cross_SHORT","Go SHORT following MA Cross")
alertcondition(ma_up,"Single_MA_LONG","Go LONG following Single MA")
alertcondition(ma_down,"Single_MA_SHORT","Go SHORT following Single MA")
Cevap Gönder
To set alert using alertcondition function add this to bottom of the script then add script to chart.

alertcondition(ma_up, title = "Buy Condition", message = "Buy Condition Alert")

alertcondition(ma_down, title = "Sell Condition", message = "Sell Condition Alert")
+3 Cevap Gönder
Thank you very much for these indicators. I'm always feeling these very useful.

And I appreciate you if you could make an optional indication with these indications.
I would like to see how these MA indicators will be shown in the near future if the price goes to an certain point in a certain time.
For example, if the price goes 10% up or down in a certain days I would like to see which point these MA indicators go to.

I wish if you could make these for us.
Best regards,
+5 Cevap Gönder
HIi All,

thank you for the indicator. A little help, I get multiple errors when I compile the script.
Cevap Gönder
For those asking for alerts based on the colour changing, try adding this to the end of the script:

isNewCol1 = nz(ma_up) and ma_down
isNewCol2 = nz(ma_down) and ma_up

plotshape(series=isNewCol2, title="Long", style=shape.triangleup, location=location.bottom, color=lime, text="Long", size=size.small)
plotshape(series=isNewCol1, title="Short", style=shape.triangledown,, color=red, text="Short", size=size.small)

alertcondition(condition=isNewCol2, title="Long", message="Long")
alertcondition(condition=isNewCol1, title="Short", message="Short")

You don't necessarily need the plotshape lines, they're just in for demo purposes.

I'm not a coder so there are probably numerous, cleaner ways to do this but the above works.
+4 Cevap Gönder
Ana Sayfa Hisse Senedi Takipçisi Forex Takipçisi Kripto Takipçisi Ekonomik Takvim Nasıl Çalışır Grafik Özellikleri Ücretlendirme Tanıdık yönlendirme Kurallarımız Destek Merkezi Web Sitesi & Aracı Kurum Çözümleri Görsel Bileşenler(Widget) Grafik Çözümleri Hafif Grafik Kitaplığı Blog ve Haberler Twitter
Profil Profil Ayarları Hesap ve Ödemeler Tanıdık yönlendirme Destek Kayıtlarım Destek Merkezi Yayınlanmış Fikirler Takip Edenler Takip ediliyor Özel Mesajlar Sohbet Çıkış