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.
Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuyla, bu betiğin yazarı, yatırımcının anlayabilmesi ve doğrulayabilmesi için onu açık kaynak olarak yayınladı. Yazarın eline sağlık! Bunu ücretsiz olarak kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Kullanım Koşulları ile yönetilir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?
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)