Rewrite the macd(trading view) code on mt5

MQL5 Indicadores Scripts

Termos de Referência

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)


Respondido

1
Desenvolvedor 1
Classificação
(468)
Projetos
530
33%
Arbitragem
28
39% / 43%
Expirado
7
1%
Ocupado
2
Desenvolvedor 2
Classificação
(563)
Projetos
932
47%
Arbitragem
302
59% / 25%
Expirado
124
13%
Ocupado
3
Desenvolvedor 3
Classificação
(254)
Projetos
573
36%
Arbitragem
64
20% / 58%
Expirado
147
26%
Livre
4
Desenvolvedor 4
Classificação
(236)
Projetos
440
26%
Arbitragem
125
21% / 57%
Expirado
96
22%
Trabalhando
5
Desenvolvedor 5
Classificação
(14)
Projetos
22
36%
Arbitragem
1
0% / 0%
Expirado
0
Livre
6
Desenvolvedor 6
Classificação
(52)
Projetos
97
24%
Arbitragem
10
20% / 20%
Expirado
12
12%
Trabalhando
7
Desenvolvedor 7
Classificação
(256)
Projetos
417
38%
Arbitragem
86
44% / 19%
Expirado
71
17%
Ocupado
8
Desenvolvedor 8
Classificação
(6)
Projetos
8
13%
Arbitragem
0
Expirado
1
13%
Livre

Informações sobre o projeto

Orçamento
30+ USD
Desenvolvedor
27 USD