i have written a PineScript Strategie in TradingView and would like to convert this in MQL5 for MetaTrader5.
Could anyone help me?
Here is the PineScript Code:
- Code: Select all
//@version=4
strategy("Cross ATR", overlay=true)
// Create Indicator's
shortEMA = ema(close, 14)
longEMA = ema(close, 100)
rsi = rsi(close, 14)
atr = atr(14)
// Specify crossover conditions
longCondition = crossover(shortEMA, longEMA)
shortCondition = crossunder(shortEMA, longEMA)
if (longCondition)
stopLoss = low - atr * 3
takeProfit = high + atr * 4
strategy.entry("long", strategy.long, 1, when = rsi > 50)
strategy.exit("exit", "long", stop=stopLoss, limit=takeProfit)
if (shortCondition)
stopLoss = high + atr * 3
takeProfit = low - atr * 4
strategy.entry("short", strategy.short, 1, when = rsi < 50)
strategy.exit("exit", "short", stop=stopLoss, limit=takeProfit)
plot(shortEMA, title = "EMA14")
plot(longEMA, title = "EMA100", color=color.green)
plot(low - atr * 3, title = "SL Long", color=color.rgb(175, 76, 76))
plot(high + atr * 3, title = "SL Short", color=color.rgb(226, 205, 19))
Thanks and best wishes