Rewrite the macd(trading view) code on mt5

MQL5 Indicadores Sripts

Tarea técnica

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)


Han respondido

1
Desarrollador 1
Evaluación
(539)
Proyectos
618
33%
Arbitraje
35
37% / 49%
Caducado
10
2%
Ocupado
2
Desarrollador 2
Evaluación
(574)
Proyectos
945
47%
Arbitraje
309
58% / 27%
Caducado
125
13%
Libre
3
Desarrollador 3
Evaluación
(264)
Proyectos
593
35%
Arbitraje
64
20% / 58%
Caducado
147
25%
Libre
Ha publicado: 1 artículo, 22 ejemplos
4
Desarrollador 4
Evaluación
(250)
Proyectos
460
26%
Arbitraje
140
20% / 59%
Caducado
100
22%
Trabaja
5
Desarrollador 5
Evaluación
(22)
Proyectos
32
44%
Arbitraje
1
0% / 0%
Caducado
0
Libre
6
Desarrollador 6
Evaluación
(54)
Proyectos
102
23%
Arbitraje
12
25% / 17%
Caducado
13
13%
Libre
7
Desarrollador 7
Evaluación
(294)
Proyectos
469
39%
Arbitraje
101
41% / 24%
Caducado
77
16%
Trabajando
Ha publicado: 2 ejemplos
8
Desarrollador 8
Evaluación
(6)
Proyectos
8
13%
Arbitraje
0
Caducado
1
13%
Libre
Ha publicado: 1 ejemplo

Información sobre el proyecto

Presupuesto
30+ USD