Convert PineScript to MQL5?

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Convert PineScript to MQL5?

Postby foxmulder12 » Fri Nov 25, 2022 3:29 am

Morning, :-)

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
foxmulder12
 
Posts: 1
Joined: Fri Nov 25, 2022 3:24 am

Re: Convert PineScript to MQL5?

Postby Apprentice » Fri Nov 25, 2022 4:45 am

We have added your request to the development list.
Development reference 772.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36399
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Re: Convert PineScript to MQL5?

Postby King786 » Wed May 31, 2023 8:00 am

Hi :
I hope you are all doing good.
Can someone help me to convert this Trading View pinescript into a MQL5 auto-trading indicator ?
Thank you

//@version=5
strategy(title="auto", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// Indicators
ema10 = ta.ema(close, 15)
ema25 = ta.ema(close, 35)
sma50 = ta.sma(close, 70)

// Buy Signal
buySignal = ema10 > ema25 and ta.crossover(ema35, sma70)

// Sell Signal
sellSignal = ema10 < ema25 and ta.crossover(sma70, ema35)

// Exit Signals
buyExitSignal = ta.crossunder(ema15, ema35)
sellExitSignal = ta.crossunder(ema35, ema15)

// Strategy Entry and Exit
if (buySignal)
strategy.entry("Buy", strategy.long)

if (sellSignal)
strategy.entry("Sell", strategy.short)

if (buyExitSignal)
strategy.close("Buy")

if (sellExitSignal)
strategy.close("Sell")
// Plot the indicators for visual analysis
plot(sma70, color=color.red)
plot(ema15, color=color.black)
plot(ema35, color=color.green)
King786
 
Posts: 1
Joined: Wed May 31, 2023 7:54 am

Re: Convert PineScript to MQL5?

Postby Apprentice » Wed May 31, 2023 1:58 pm

We have added your request to the development list.
Development reference 490.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36399
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 5 guests