//Created by user ChrisMoody 4-24-2014 //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", shorttitle="CM_Ultimate_MA_MTF", 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") atype = input(1,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA") cc = input(true,title="Change Color Based On Direction?") smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - 1 = No Smoothing") doma2 = input(false, title="Optional 2nd Moving Average") len2 = input(50, title="Moving Average Length - Optional 2nd MA") atype2 = input(1,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA") 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 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) : tema //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 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) : tema out = avg out_two = avg2 out1 = security(tickerid, res, out) out2 = security(tickerid, res, out_two) 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 : aqua 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=5, color=yellow)
CheckBox Allows use on higher or Lower TimeFrame
CheckBox Allows Switching From MA Color Based On Trend - To a Single Color
Input For Color Smoothing
***Ability to Plot 2nd Moving Average
2nd Ma Can Be A Completely Different Type of MA
Separate Control to Color 2nd MA based on Trend, or One Solid color.
Ability to Plot Crosses of Moving Averages - Even if 2nd Ma isn’t Plotted
SMA - Simple Moving Average
EMA - Exponential MA
WMA - Weighted MA
HullMA - Hull Moving Average
VWMA - Volume Weighted Moving Average
RMA - No Idea but TV Has It. Similar to EMA, MA Used To Calculate RSI.
TEMA - Tripple Exponential Moving Average
***More Updates To Come.
***Adding More MA Plot Capabilities.
***Adding “Fill” Feature between MA’s
***Adding Bars Since Cross Feature
***Adding Horizontal Lines at Cross Feature
***Leave comment below and you will be automatically notified on Updates.
If I left any type of MA out that you want…leave comment below and I will try and add.
Video On Importing Custom Indicator from PasteBin Link Below:
PasteBin Link To Code:
don't work on my Amibroker, latest version
got the message:
Syntax error, unexpected identifier
There is a small update you can try. This version fixes one small bug I found and someone requested a Highlight Bar option if price is Crossing MA 1 or MA 2. I set that as a Check Box Option with default color set to yellow. (Only plots if Price Crosses MA, doesn't plot in Gap Situation)
If you still have a problem PM me and we will need to do a screen share. I've verified it works on my end. So if you change the MA type to 7 which equals TEMA MA and then press OK ... at the top of screen is should show (true, D, 20, 7) True means use chart resolution, D means the timeframe the MA is calculationg off of, 20 means the period, 1 means the MA Type, ... so if you change the period from 20 to 50 for example and the MA type from 1 to 2 which is a EMA and press OK...on your screen you should see (true, D, 50, 2 etc....
Please let me know if your still having a issue...I want to get this solved for you
short = crossunder(n1, n2)
long = crossover(n1, n2)
plot(long, "Long", color=green)
plot(short, "Short", color=red)
Credit to Hull MA by mohamed982.
Create an alert on it, on candle close, crossing down 0.8. One alert for each Long and Short.
It's strange when I put two of that indicator at the same time. The lines are moving in a strange way when I zoom or move the chart. for example the 200ema can be above or under the bars. The stranger thing is that this bug appear only when I save my two indicators as a study template and I add it to another chart.
In short, when I put those two indicator, it works. When I need them as a study template, it dies these strange things. Do you have an explication?
I'm looking to put 4 différent EMA lines (15, 30, 50 and 200) and I need them to change color when they go up or down. Do you have something that can make that?
I have made a screen capture to let you see what exactly happen.