How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

# Ultimate Moving Average-Multi-TimeFrame-7 MA Types

29467 30
All Moving Averages and Features Built In To ONE Indicator. The Only Moving Average Indicator You Will Need. Details In 1st Post.
```//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

***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://pastebin.com/UP4wa8nV
ChrisMoody
2nd Ma Turned on w/ no Directional Color Coding and Crosses Plotted at Cross

ChrisMoody
@ChrisMoody,
got the message:
Error 30
Syntax error, unexpected identifier
ChrisMoody
@ChrisMoody, LET ME TELL MY STORY , I GOT INVOLVED IN THE BINARY OPTIONS THING AS A WAY TO DOUBLE MY RETIREMENT FUNDS BUT IT BACKFIRED ON ME , I LOST ALL MY MONEY. I DIDN'T GIVE UP , I FOUGHT DIRTY BY HIRING A PROFESSIONAL HACKER TO RETRIEVE MY FUNDS. THEY GOT MY MONEY OUT FOR ME ALMOST 189,000POUNDS I THOUGHT I HAD LOST. EMAIL AMYSHELDON95@GMAIL.COM IF YOU NEED TO GET SIMILAR HELP, I'LL POINT YOU THE RIGHT WAY
amysheldon95gmailcom
@amysheldon95gmailcom,

Thanks
TASAVANT
This is really great Chris, thanks...
pezq
No Problem...Thanks
I just noticed that the Multi-TimeFrame 7 MA Types actually plots the SMA 20. No difference between the two in plotting.
sublimares2
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
ChrisMoody
Daily JCP- both line are plotted on top of each other
sublimares2
ChrisMoody
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.
sublimares2
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
ChrisMoody
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
sublimares2
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.
squattter
did you ever get a script to set an alert on this great chart?
sorchard
actually yes, but i have no need for it anymore - method has changed a lot since, but i'll get it for you.

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.
squattter
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). :)
sorchard
give me a yell if you get stuck
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.

Thanks again,
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
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.
Hi, Chris
Does it work on TOS?
Baur999
ThinkOrSwim uses a different coding language.
Hi Chris
Thanks very much for this
Have been using this to time entrys of stock recommendations--with much improved results, esp exits
Cheers
Line 39 you calculate stema variable, in line 41 you use tema instead, is it correct?
Hi Chris
Still trying to understand 'script' but is this purely a MA cross or can it be set to detect price crossing?
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder 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