Rewrite the macd(trading view) code on mt5

MQL5 지표 스크립트

명시

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)


응답함

1
개발자 1
등급
(489)
프로젝트
557
33%
중재
27
44% / 44%
기한 초과
8
1%
바쁜
2
개발자 2
등급
(564)
프로젝트
933
47%
중재
302
59% / 25%
기한 초과
125
13%
로드됨
3
개발자 3
등급
(254)
프로젝트
573
36%
중재
64
20% / 58%
기한 초과
147
26%
무료
4
개발자 4
등급
(236)
프로젝트
440
26%
중재
125
21% / 57%
기한 초과
96
22%
작업중
5
개발자 5
등급
(16)
프로젝트
24
38%
중재
1
0% / 0%
기한 초과
0
작업중
6
개발자 6
등급
(52)
프로젝트
97
24%
중재
11
18% / 18%
기한 초과
12
12%
작업중
7
개발자 7
등급
(261)
프로젝트
425
38%
중재
86
44% / 19%
기한 초과
71
17%
로드됨
8
개발자 8
등급
(6)
프로젝트
8
13%
중재
0
기한 초과
1
13%
무료

프로젝트 정보

예산
30+ USD
개발자에게
27 USD