PineScript to MQL5

MQL5 Convertir

Tâche terminée

Temps d'exécution 3 heures
Commentaires du client
Amazing Guy! It just took 2 hours for him to complete the job! Indicator works great!
Commentaires de l'employé
Great customer. I hope we will have more cooperation

Spécifications

Hi Guys, I want to translate this indicator's code:

//@version=4
study(title="=Testing", overlay = true)

// Inputs
a = input(1,     title = "Key Vaule. 'Sensitivity'") // Please rename it "SENSITIVITY"
c = input(2,    title = "ATR Period") // Please rename to "ATR_PERIOD"

xATR  = atr(c)
nLoss = a * xATR

src = close

xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
   iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss), 
   iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
 
pos = 0   
pos :=  iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
   iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) 
   
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue 

ema   = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)

buy  = src > xATRTrailingStop and above 
sell = src < xATRTrailingStop and below

barbuy  = src > xATRTrailingStop 
barsell = src < xATRTrailingStop 

plotshape(buy,  title = "Buy",  text = 'Buy',  style = shape.labelup,   location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red,   textcolor = color.white, transp = 0, size = size.tiny)

barcolor(barbuy  ? color.green : na)
barcolor(barsell ? color.red   : na)

alertcondition(buy,  "Long",  "Long")
alertcondition(sell, "Short", "Short")
to the MQL5 code.

Best if the code would run as bar closes/opens new one.

The "barcolor" is not needed.

Also, the "plotshape" part is not needed, when the "Sell" or "Buy" event appears I just want it to add a vertical line (or whatever with green or red color) and Print in the console "Starting LONG" / "STARTING SHORT".

I will want to build EA on top of this so I will need the source code.

Please run this part of code inside TradingView and see how it works.

While rewriting this code please add comments to each function/line that represents some functionality.

Any questions - just ask.

Répondu

1
Développeur 1
Évaluation
(100)
Projets
125
23%
Arbitrage
12
0% / 75%
En retard
22
18%
Gratuit
2
Développeur 2
Évaluation
(412)
Projets
543
75%
Arbitrage
9
44% / 0%
En retard
24
4%
Gratuit

Informations sur le projet

Budget
30+ USD