Bollinger Bands EA (Convert from Pine Script to MQ4L)

MQL4 エキスパート

指定

Hello, I'd need help to code a simple EA based on Bollinger Bands indicator. The code is below in Pine Script (from Trading View platform) and need to convert it to Metatrader MT4

thanks


//////// 

len = input(20, minval=1, title="Length") 
multiplier = input(2, minval=1, title="multiplier") 
trendTimeFrame = input(60, minval=1, title="Trend Time Frame") 
useTrendFilter = input(true, type=bool, title = "Use Trend Filter") 

src = input(close, title="Source") 
out = sma(src, len) 
//plot(out, title="SMA", color=blue) 

stdOut = stdev(close, len) 
bbUpper = out + stdOut * multiplier 
bbLower = out - stdOut * multiplier 
bbUpper2 = out + stdOut * (multiplier / 2) 
bbLower2 = out - stdOut * (multiplier / 2) 
bbUpperX2 = out + stdOut * multiplier * 2 
bbLowerX2 = out - stdOut * multiplier * 2 
bbWidth = (bbUpper - bbLower) / out 


closeLongTerm = security(tickerid, tostring(trendTimeFrame), close) 
smaLongTerm = security(tickerid, tostring(trendTimeFrame), sma(close,20)) 

//plot(smaLongTerm, color=red) 

trendUp = useTrendFilter ? (closeLongTerm > smaLongTerm) : true 
trendDown = useTrendFilter? (closeLongTerm < smaLongTerm) : true 

bearish = ((cross(close,bbUpper2) == 1) or (cross(close,out) == 1)) and (close[1] > close) and trendDown 
bullish = ((cross(close,bbLower2) == 1) or (cross(close,out) == 1)) and (close[1] < close) and trendUp 


closeBuy = (high[1] > bbUpper[1]) and (close < bbUpper) and (close < open) and trendUp 
closeSell = (((low[1] bbLower)) or ((low[2] bbLower[1]))) and (close > open) and trendDown 


cutLossBuy = iff(bbWidth > 0.005, (low bbLower[1]) and trendUp, (low bbLowerX2[1]) and trendUp) 
cutLossSell = iff(bbWidth > 0.005, (high > bbUpper) and (high[1] bbUpperX2) and (high[1] < bbUpperX2[1]) and trendDown) 


if (bullish) 
strategy.entry("Buy", strategy.long, comment="Buy") 

if (bearish) 
strategy.entry("Sell", strategy.short, comment="Sell") 


strategy.close("Buy", closeBuy or cutLossBuy) 

strategy.close("Sell", closeSell or cutLossSell)

応答済み

1
開発者 1
評価
(356)
プロジェクト
632
26%
仲裁
89
73% / 13%
期限切れ
12
2%
2
開発者 2
評価
(236)
プロジェクト
440
26%
仲裁
124
21% / 56%
期限切れ
96
22%
取り込み中
3
開発者 3
評価
(15)
プロジェクト
14
36%
仲裁
10
0% / 90%
期限切れ
4
29%

プロジェクト情報

予算
30+ USD
開発者用
27 USD