Rewrite the macd(trading view) code on mt5

MQL5 Indicatori Script

Specifiche

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)


Con risposta

1
Sviluppatore 1
Valutazioni
(489)
Progetti
557
33%
Arbitraggio
27
44% / 44%
In ritardo
8
1%
Occupato
2
Sviluppatore 2
Valutazioni
(564)
Progetti
933
47%
Arbitraggio
302
59% / 25%
In ritardo
125
13%
Caricato
3
Sviluppatore 3
Valutazioni
(254)
Progetti
573
36%
Arbitraggio
64
20% / 58%
In ritardo
147
26%
Gratuito
4
Sviluppatore 4
Valutazioni
(236)
Progetti
440
26%
Arbitraggio
125
21% / 57%
In ritardo
96
22%
In elaborazione
5
Sviluppatore 5
Valutazioni
(16)
Progetti
24
38%
Arbitraggio
1
0% / 0%
In ritardo
0
In elaborazione
6
Sviluppatore 6
Valutazioni
(52)
Progetti
97
24%
Arbitraggio
11
18% / 18%
In ritardo
12
12%
In elaborazione
7
Sviluppatore 7
Valutazioni
(261)
Progetti
425
38%
Arbitraggio
86
44% / 19%
In ritardo
71
17%
Caricato
8
Sviluppatore 8
Valutazioni
(6)
Progetti
8
13%
Arbitraggio
0
In ritardo
1
13%
Gratuito

Informazioni sul progetto

Budget
30+ USD
Per lo sviluppatore
27 USD