Convert my tradingview indicator script into a MT4 EA or indicator

MQL4 转化中

工作已完成

执行时间12 小时

指定

//@version=4
study("Custom", overlay = true)
//Var dec
length = 9
fractionalMult = input(title="Key Value", step=1, defval=1)

tr2() =>
max(high - low, max(abs(high - close[1]), abs(low - close[1])))

//Calc delta
calc1(in1, in2) =>
alpha = in2
sum = 0.0
sum := (in1 + (alpha - 1) * nz(sum[1])) / alpha

value1 = fractionalMult * calc1(tr2(), length)

sigShort = hl2 + value1
sigShortPrev = nz(sigShort[1], sigShort)
sigLong = hl2 - value1
sigLongPrev = nz(sigLong[1], sigLong)

sigLong := close[1] > sigLongPrev ? max(sigLong, sigLongPrev) : sigLong
sigShort := close[1] < sigShortPrev ? min(sigShort, sigShortPrev) : sigShort

dir = 1
dir := nz(dir[1], dir)
//Filter extreme moves
dir := dir == -1 and close > sigShortPrev ? 1 : dir == 1 and close < sigLongPrev ? -1 : dir

alertcondition( dir[1] == -1 and dir == 1 ? sigLong : na, "BUY", "BUY")
alertcondition(dir[1] == 1 and dir == -1 ? sigShort : na, "SELL", "SELL")

//plot
plotshape(dir == 1 and dir[1] == -1 ? sigLong : na, title="LONG", style=shape.labelup, location=location.belowbar, size=size.normal, text="LONG", textcolor = color.white, color=http://color.green)
plotshape(dir == -1 and dir[1] == 1 ? sigShort : na, title="SHORT", style=shape.labeldown, location=location.abovebar, size=size.normal, text="SHORT", textcolor = color.white, color=http://color.red)


反馈

1
开发者 1
等级
(851)
项目
1464
72%
仲裁
122
29% / 48%
逾期
358
24%
工作中
发布者: 3 文章
2
开发者 2
等级
(337)
项目
624
38%
仲裁
40
23% / 65%
逾期
93
15%
空闲
发布者: 4 文章, 19 代码
3
开发者 3
等级
(590)
项目
789
71%
仲裁
9
33% / 33%
逾期
22
3%
空闲
发布者: 8 代码
4
开发者 4
等级
(4)
项目
4
0%
仲裁
5
0% / 80%
逾期
1
25%
空闲
5
开发者 5
等级
(647)
项目
1295
67%
仲裁
84
26% / 49%
逾期
338
26%
空闲

项目信息

预算
30+ USD
截止日期
 1 天