FantasticFox

MACD Divergence MultiTimeFrame [FantasticFox]

This is a MACD divergence on 3 time-frames, 1h, 4h and 1D.
Please insert the indicator into a 1h chart, otherwise change the lengths' inputs.

you will see H1,H2, H3, R1, R2 and R3 in green and maroon colors.
H means hidden divergence, 1 regards to 1h, 2 to 4h, and 3 to 1D. If the color is green, its bullish , and if its maroon the divergence is bearish .

Gray circles on 4h macd is for those traders who want to check the confirmation on Elliott wave changes.

*Thanks to RicardoSantos MACD divergence.
Remove from Favorite Scripts Add to Favorite Scripts
study(title='MACD Divergence MultiTimeFrame [FantasticFox]', shorttitle='MACD Div MTF')
source = input(close)

f_top_indy(_source)=>_source[4] < _source[2] and _source[3] < _source[2] and _source[2] > _source[1] and _source[2] > _source[0]
f_bot_indy(_source)=>_source[4] > _source[2] and _source[3] > _source[2] and _source[2] < _source[1] and _source[2] < _source[0]
f_indyize(_source)=>f_top_indy(_source) ? 1 : f_bot_indy(_source) ? -1 : 0

fastLength1 = input(12, minval=1), slowLength1=input(26,minval=1)
fastMA1 = ema(source, fastLength1)
slowMA1 = ema(source, slowLength1)
macd1 = fastMA1 - slowMA1 
plot(macd1, color=aqua, linewidth=1)


indy_top1 = f_indyize(macd1) > 0 ? macd1[2] : na
indy_bot1 = f_indyize(macd1) < 0 ? macd1[2] : na

high_prev1 = valuewhen(indy_top1, macd1[2], 1) 
high_price1 = valuewhen(indy_top1, high[2], 1)
low_prev1 = valuewhen(indy_bot1, macd1[2], 1) 
low_price1 = valuewhen(indy_bot1, low[2], 1)

regular_bearish_div1 = indy_top1 and high[2] > high_price1 and macd1[2] < high_prev1
hidden_bearish_div1 = indy_top1 and high[2] < high_price1 and macd1[2] > high_prev1
regular_bullish_div1 = indy_bot1 and low[2] < low_price1 and macd1[2] > low_prev1
hidden_bullish_div1 = indy_bot1 and low[2] > low_price1 and macd1[2] < low_prev1


plotshape(title='+RD', series=regular_bearish_div1 ? macd1[2] : na, text='R1', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='+HD', series=hidden_bearish_div1 ? macd1[2] : na, text='H1', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='-RD', series=regular_bullish_div1 ? macd1[2] : na, text='R1', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
plotshape(title='-HD', series=hidden_bullish_div1 ? macd1[2] : na, text='H1', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)

/////// 4h

fastLength2 = input(48, minval=1), slowLength2=input(104,minval=1)
fastMA2 = ema(source, fastLength2)
slowMA2 = ema(source, slowLength2)
macd2 = fastMA2 - slowMA2
plot(macd2, color=aqua, linewidth=1)


indy_top2 = f_indyize(macd2) > 0 ? macd2[2] : na
indy_bot2 = f_indyize(macd2) < 0 ? macd2[2] : na

high_prev2 = valuewhen(indy_top2, macd2[2], 1) 
high_price2 = valuewhen(indy_top2, high[2], 1)
low_prev2 = valuewhen(indy_bot2, macd2[2], 1) 
low_price2 = valuewhen(indy_bot2, low[2], 1)

regular_bearish_div2 = indy_top2 and high[2] > high_price2 and macd2[2] < high_prev2
hidden_bearish_div2 = indy_top2 and high[2] < high_price2 and macd2[2] > high_prev2
regular_bullish_div2 = indy_bot2 and low[2] < low_price2 and macd2[2] > low_prev2
hidden_bullish_div2 = indy_bot2 and low[2] > low_price2 and macd2[2] < low_prev2


plotshape(title='+RD', series=regular_bearish_div2 ? macd2[2] : na, text='R2', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='+HD', series=hidden_bearish_div2 ? macd2[2] : na, text='H2', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='-RD', series=regular_bullish_div2 ? macd2[2] : na, text='R2', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
plotshape(title='-HD', series=hidden_bullish_div2 ? macd2[2] : na, text='H2', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)

////////// 1D

fastLength3 = input(288, minval=1), slowLength3=input(624,minval=1)
fastMA3 = ema(source, fastLength3)
slowMA3 = ema(source, slowLength3)
macd3 = fastMA3 - slowMA3
plot(macd3, color=aqua, linewidth=1)


indy_top3 = f_indyize(macd3) > 0 ? macd3[2] : na
indy_bot3 = f_indyize(macd3) < 0 ? macd3[2] : na

high_prev3 = valuewhen(indy_top3, macd3[2], 1) 
high_price3 = valuewhen(indy_top3, high[2], 1)
low_prev3 = valuewhen(indy_bot3, macd3[2], 1) 
low_price3 = valuewhen(indy_bot3, low[2], 1)

regular_bearish_div3 = indy_top3 and high[2] > high_price3 and macd3[2] < high_prev3
hidden_bearish_div3 = indy_top3 and high[2] < high_price3 and macd3[2] > high_prev3
regular_bullish_div3 = indy_bot3 and low[2] < low_price3 and macd3[2] > low_prev3
hidden_bullish_div3 = indy_bot3 and low[2] > low_price3 and macd3[2] < low_prev3


plotshape(title='+RD', series=regular_bearish_div3 ? macd3[2] : na, text='R3', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='+HD', series=hidden_bearish_div3 ? macd3[2] : na, text='H3', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='-RD', series=regular_bullish_div3 ? macd3[2] : na, text='R3', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
plotshape(title='-HD', series=hidden_bullish_div3 ? macd3[2] : na, text='H3', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
///////////////

plot(title='H D', series=indy_top2, style=circles, color=regular_bearish_div2 or hidden_bearish_div2 ? maroon : gray, linewidth=3, offset=-2)
plot(title='L D', series=indy_bot2, style=circles, color=regular_bullish_div2 or hidden_bullish_div2 ? green : gray, linewidth=3, offset=-2)

Thanks for this awesome indicator, can you please explain more regarding "Gray circles on 4h macd is for those traders who want to check the confirmation on Elliott wave changes" ?
Thanks
+5 Reply
how to set an alert? please help.
+10 Reply
Signals are very late...
+2 Reply
You have done wonderful job. Can you please explain where do I change this setting? "lease insert the indicator into a 1h chart, otherwise change the lengths' inputs."
Reply
"Please insert the indicator into a 1h chart, otherwise change the lengths' inputs"
where I change it, please? Which line?
thank you
+4 Reply
VishalDesai Najjar-Nidhal
@Najjar-Nidhal, Did you find? where to change setting to 4h
Reply
Thank you it's good !!
"H means hidden divergence, 1 regards to 1h, 2 to 4h, and 3 to 1D. If the color is green, its bullish , and if its maroon the divergence is bearish ." but also it works at 1,2,5,30 min so what's means there 1,2,3 plz?
Reply
does it repaint? redraw ? does the signals come late ? what are the flaws
+7 Reply
@djmc, Totally agree.. they are late
Reply
OMG
+1 Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Get Help Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing Get Help Ideas Published Followers Following Private Messages Chat Sign Out