Convert Pine Script to MT5 EA and add some features

MQL5 Experts Converting

Specification

Convert the below code to an MT5 EA: 


//@version=4

strategy("Volty Expan Close Strategy", overlay=true)

length = input(11)

numATRs = input(0.55)


atrs = sma(tr, length)*numATRs


if (not na(close[length]))

    strategy.entry("VltClsLE", strategy.long, stop=close+atrs, comment = "VltClsLE")

    strategy.entry("VltClsSE", strategy.short, stop=close-atrs, comment = "VltClsSE")


//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)


And add some additional features:

  • Stop Loss,
  • Trailing Stop (with trailing start, trailing distance, and trailing step)
  • option to close on opposite signal, true or false
  • If the strategy is in a buy signal, once the initial buy trade closes, place a buy stop order X points (the Offset) above the current price. The Offset amount should be an input parameter
    • The buy stop order should follow the market price. So let's say the first buy trade closes at 5500.00. If the Offset is set to 200 points, a new buy stop order is placed at 5502.00. but if the price falls to 5499.00, the buy stop order should move down to 5501.00. but it should never move back up. Apply the same logic to the sell side.
  • There should only be one trade open per direction at any time. but a buy and sell trade can exist simultaneously (if close on opposite signal is set to false), if a sell signal is triggered while a buy trade is still open, and vice versa.
  • Essentially, i am asking you to recreate an already existing EA, which i will send to you in a private discussion, but have it only enter buy trades when the above Pine Script strategy is in a buy signal, and only enter sell trades when it is in a sell signal. It basically just needs to be modified so that it determines buy/sells according to the above strategy, instead of its existing strategy, which tends to always be trading against the trend.




Responded

1
Developer 1
Rating
(1)
Projects
0
0%
Arbitration
2
0% / 100%
Overdue
0
Free
2
Developer 2
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
3
Developer 3
Rating
Projects
1
0%
Arbitration
1
0% / 0%
Overdue
0
Free
4
Developer 4
Rating
(206)
Projects
333
35%
Arbitration
66
12% / 58%
Overdue
87
26%
Free
5
Developer 5
Rating
(2)
Projects
3
0%
Arbitration
1
0% / 100%
Overdue
0
Working
6
Developer 6
Rating
(1)
Projects
2
0%
Arbitration
1
0% / 100%
Overdue
0
Free
Published: 2 codes
7
Developer 7
Rating
Projects
1
0%
Arbitration
0
Overdue
0
Working
8
Developer 8
Rating
(845)
Projects
1447
72%
Arbitration
119
29% / 47%
Overdue
355
25%
Working
Published: 3 articles
9
Developer 9
Rating
(27)
Projects
38
24%
Arbitration
14
0% / 93%
Overdue
4
11%
Free
10
Developer 10
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
11
Developer 11
Rating
Projects
0
0%
Arbitration
1
0% / 100%
Overdue
0
Free
12
Developer 12
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
13
Developer 13
Rating
(337)
Projects
624
38%
Arbitration
40
23% / 65%
Overdue
93
15%
Free
Published: 4 articles, 19 codes
14
Developer 14
Rating
(120)
Projects
128
36%
Arbitration
3
33% / 33%
Overdue
2
2%
Loaded
15
Developer 15
Rating
(275)
Projects
370
72%
Arbitration
18
33% / 44%
Overdue
14
4%
Free
Published: 14 codes
16
Developer 16
Rating
(15)
Projects
21
38%
Arbitration
6
33% / 50%
Overdue
0
Working

Project information

Budget
30+ USD

Customer

(2)
Placed orders9
Arbitrage count0