ChrisMoody

Ultimate Moving Average-Multi-TimeFrame-7 MA Types

All Moving Averages and Features Built In To ONE Indicator. The Only Moving Average Indicator You Will Need. Details In 1st Post.
Remove from Favorite Scripts Add to Favorite Scripts
//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)

Defaults to Current Chart TimeFrame
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:
http://blog.tradingview.com/?p=265

PasteBin Link To Code:
http://pastebin.com/UP4wa8nV
Reply
ChrisMoody PRO ChrisMoody
2 years ago
2nd Ma Turned on w/ no Directional Color Coding and Crosses Plotted at Cross

snapshot
Reply
TASAVANT
2 years ago
Thanks
Reply
pezq PRO TASAVANT
2 years ago
This is really great Chris, thanks...
Reply
ChrisMoody PRO pezq
2 years ago
No Problem...Thanks
Reply
sublimares2
2 years ago
I just noticed that the Multi-TimeFrame 7 MA Types actually plots the SMA 20. No difference between the two in plotting.
Reply
ChrisMoody PRO sublimares2
2 years ago
I checked it on many different charts on several different timeframes using with and without Multi Time Frames and it worked for me. Value of setting 7 which is TEMA is different from all others and works whether using it on 1st ma or 2nd ma. Please try again and if it is still happening please let me know the exact symbol and timeframe your using it on and any settings you've changed from default.

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)

CM_Ult_MA_MTF_V1
http://pastebin.com/HhnxKcpy
Reply
sublimares2 ChrisMoody
2 years ago
Daily JCP- both line are plotted on top of each other
Reply
sublimares2 sublimares2
2 years ago
snapshot
Reply
sublimares2 ChrisMoody
2 years ago
I have now the latest version you posted above- same result on all time frames. Even Fibo bands from LazyBear shows the middle point of the bands is plotting the same MA20.
snapshot
Reply
ChrisMoody PRO sublimares2
2 years ago
I just duplicated your exact settings on a JCP daily chart. On top left of screen where it shows the name of the indicator the settings on your chart say (true, D, 20, 1 etc.) That last 1 means it is set to a SMA...if it said 2 that would be EMA, 7 would me TEMA. So I think the issue is when you have the inputs tab open if you change the MA type from 1 to 7 then in real time you see adjustments. But you have to hit OK at the bottom. If you X out on the top right of the tab all the settings will go back to default...which is the setting of 1 which + SMA.

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
Reply
sublimares2 ChrisMoody
2 years ago
Thank you Chris- much appreciate it your help. I guess I figured out now. I can see now by numbers one can change the type of MA and the timeframe of the chart. Solved:) Thank you from
snapshot
Reply
ChrisMoody PRO sublimares2
2 years ago
Great...Glad its Working
Reply
squattter PRO
2 years ago
Thanks for this.
Is there anyway to set an alert for when the colours change/cross over? I've tried pretty much every combination crossing but can't get it to happen on the colour change. Thanks.
+1 Reply
sorchard PRO squattter
a year ago
did you ever get a script to set an alert on this great chart?
Reply
squattter PRO sorchard
a year ago
actually yes, but i have no need for it anymore - method has changed a lot since, but i'll get it for you.

snapshot


study("HullMA",overlay=false)
n=input(title="period",type=integer,defval=34)


n2ma=2*wma(close,round(n/2))
nma=wma(close,n)
diff=n2ma-nma
sqn=round(sqrt(n))


n2ma1=2*wma(close,round(n/2))
nma1=wma(close,n)
diff1=n2ma1-nma1
sqn1=round(sqrt(n))


n1=wma(diff,sqn)
n2=wma(diff1,sqn)
c=n1>n2?green:red


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.
Reply
sorchard PRO squattter
a year ago
thanks a lot..I will see if I can get it to work...just wanted a simple chart signal, but turns out to be a complicated alert (for a beginner). :)
Reply
squattter PRO sorchard
a year ago
give me a yell if you get stuck
Reply
First of all, tanks for your work.

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.

https://www.youtube.com/watch?v=24I-gvF8Hiw&feature=youtu.be

Thanks again,
Reply
Thanks for your work - really helpful! Is it possible to add 1 month time frame? I would like to see how 4 EMA on a month chart is on an hourly chart. Thanks
Reply
pcmourao
a year ago
Hey Chris, how are you. I have been using this script created by you so that i can see the Daily 5 day moving average on the chart while i am on a 5 minute timeframe. My question to you is if i can change the settings to calculate the 5 day moving average based on the High or the Low instead of being calculated based on the close.
Reply
Baur999
7 months ago
Hi, Chris
Does it work on TOS?
Reply
ChrisMoody PRO Baur999
7 months ago
ThinkOrSwim uses a different coding language.
Reply
BB3 PRO
2 months ago
Hi Chris
Thanks very much for this
Have been using this to time entrys of stock recommendations--with much improved results, esp exits
Cheers
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out