Rewrite the macd(trading view) code on mt5

MQL5 Indicateurs Scripts

Spécifications

rewrite the macd(trading view) code on mt5

//@version=5
indicator(title="Moving Average Convergence Divergence", shorttitle="MACD", timeframe="", timeframe_gaps=true)
// Getting inputs
fast_length = input(title = "Fast Length", defval = 12)
slow_length = input(title = "Slow Length", defval = 26)
src = input(title = "Source", defval = close)
signal_length = input.int(title = "Signal Smoothing",  minval = 1, maxval = 50, defval = 9, display = display.data_window)
sma_source = input.string(title = "Oscillator MA Type",  defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
sma_signal = input.string(title = "Signal Line MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal

alertcondition(hist[1] >= 0 and hist < 0, title = 'Rising to falling', message = 'The MACD histogram switched from a rising to falling state')
alertcondition(hist[1] <= 0 and hist > 0, title = 'Falling to rising', message = 'The MACD histogram switched from a falling to rising state')

hline(0, "Zero Line", color = color.new(#787B86, 50))
plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))
plot(macd,   title = "MACD",   color = #2962FF)
plot(signal, title = "Signal", color = #FF6D00)


Répondu

1
Développeur 1
Évaluation
(496)
Projets
567
33%
Arbitrage
27
44% / 44%
En retard
9
2%
Chargé
2
Développeur 2
Évaluation
(564)
Projets
933
47%
Arbitrage
303
59% / 25%
En retard
125
13%
Travail
3
Développeur 3
Évaluation
(254)
Projets
575
36%
Arbitrage
64
20% / 58%
En retard
147
26%
Gratuit
4
Développeur 4
Évaluation
(236)
Projets
440
26%
Arbitrage
125
21% / 57%
En retard
96
22%
Travail
5
Développeur 5
Évaluation
(18)
Projets
27
41%
Arbitrage
1
0% / 0%
En retard
0
Gratuit
6
Développeur 6
Évaluation
(52)
Projets
97
24%
Arbitrage
11
18% / 18%
En retard
12
12%
Travail
7
Développeur 7
Évaluation
(261)
Projets
428
38%
Arbitrage
87
44% / 18%
En retard
71
17%
Occupé
8
Développeur 8
Évaluation
(6)
Projets
8
13%
Arbitrage
0
En retard
1
13%
Gratuit

Informations sur le projet

Budget
30+ USD
Pour le développeur
27 USD