MacD Custom Indicator-Multiple Time Frame+All Available Options!

This MacD Indicator has every feature available. See First Post for Details.
Remove from Favorite Scripts Add to Favorite Scripts
//Created by user ChrisMoody updated 4-10-2014
//Regular MACD Indicator with Histogram that plots 4 Colors Based on Direction Above and Below the Zero Line
//Update allows Check Box Options, Show MacD & Signal Line, Show Change In color of MacD Line based on cross of Signal Line.
//Show Dots at Cross of MacD and Signal Line, Histogram can show 4 colors or 1, Turn on and off Histogram.
//Special Thanks to that incredible person in Tech Support whoem I won't say you r name so you don't get bombarded with emails
//Note the feature Tech Support showed me on how to set the default timeframe of the indicator to the chart Timeframe, but also allow you to choose a different timeframe.
//By the way I fully disclose that I completely STOLE the Dots at the MAcd Cross from "TheLark"

study(title="CM_MacD_Ult_MTF", shorttitle="CM_Ult_MacD_MTF")
source = close
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60")
smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
sh = input(true, title="Show Histogram?")
macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
hist_colorChange = input(true,title="MacD Histogram 4 Colors?")

res = useCurrentRes ? period : resCustom

fastLength = input(12, minval=1), slowLength=input(26,minval=1)

fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)

macd = fastMA - slowMA
signal = sma(macd, signalLength)
hist = macd - signal

outMacD = security(tickerid, res, macd)
outSignal = security(tickerid, res, signal)
outHist = security(tickerid, res, hist)

histA_IsUp = outHist > outHist[1] and outHist > 0
histA_IsDown = outHist < outHist[1] and outHist > 0
histB_IsDown = outHist < outHist[1] and outHist <= 0
histB_IsUp = outHist > outHist[1] and outHist <= 0

//MacD Color Definitions
macd_IsAbove = outMacD >= outSignal
macd_IsBelow = outMacD < outSignal

plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray
macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime

circleYPosition = outSignal
plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2)
plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram, linewidth=4)
plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=circles, linewidth=4, color=macd_color)
hline(0, '0 Line', linestyle=solid, linewidth=2, color=white)
Hi Chris,
Please advise how to get the 4-hour time frame for this indicator.
please add ithink its usefull
Would be great if the lines would be scaled so the histogram always take most of the vertical space, sometimes specially when using slower MACDs the lines goes so high/low that the histogram bars become tiny
Hi Chris, is it possible to remove 30 and 45min and add in 4H? thanks in advance. Your indicators are superb! Cheers.
+1 Reply
Thank you~ ^_^b
Hi. Great indicator!!!
Does it re-paint? I just had it show buy-sell-buy quiet rapidly, then I refreshed the page and it just showed the first buy. Should it really do this? Is that not repainting in some way?
The signal can change on the current bar on the chart since it's still forming...the conditions can change intra-bar. However will not repaint after the bar has closed. I would never code anything that repaints historically. In my opinion that would be unethical...and unfortunately you would be surprised how many Trading Educators that sell Indicators do just that...there stuff looks amazing in hindsight...but trade with it live and it's a whole different story.

So on this indicator...Consider it only a signal once the current bar CLOSES....
tradersf ChrisMoody
Please correct me if I'm wrong but I find this indicator no different to using a standard MACD. I used it like this; 3 minute chart with 45min MACD setting. During the 45 minute bar, it whip-sawed and gave multiple signals (buy-sell-buy and so-on) until the 45 minute bar was closed. Then it used the earliest correct signal when refreshed. So this means ( as you have answered ) you have to wait for the bar to close to get the correct signal. Therefore it is of no special use because it gives the same signal if I was using a 45 minute chart and a standard MACD. I would have to wait for the 45 minute bar to close and then use the signal. Is this not correct? I can't see how this indicator is any different to the standard MACD.
Also I do agree with you that many of the strategies on this site re-paint and give false results.
Your absolutely right. On a Standard MAD the signal isn't valid until the bar closes on whatever time frame your using it on.

The purpose for this indicator is 1 thing and only 1 thing. I had requests from many people to to (For Example) View the values of a Hourly or Daily MACD on let's say a 15 minute chart. So I coded it to show people how to.

I believe most of there thought process were if (Again just a example.) If the Daily MACD was Bullish....and then you get a pullback and entry to the upside on a 60 minute chart...they wanted to take that trade going with the Trend per se.

I just coded it per requests. That is what the indicator does....Nothing More....Nothing Less.

Hope that clarifies it for you.
United States
United Kingdom
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
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out