2019.08.21 Experts Converting

## Specification

Hello,

I need to convert the Super Trend 2 Strategy from Tradingview Pine Script to MetaTrader 4 EA, so that it can open and close orders on its own.

Supertrend is a strategy by breizh29 using *rajandran.r* Supertrend Indicator, and here is the original code:

strategy("Super Trend 2", overlay=true, default_qty_value=100)

res = input(title="Main SuperTrend Time Frame", type=resolution, defval="120")

Factor=input(1, minval=1,maxval = 100)

Pd=input(1, minval=1,maxval = 100)

tp = input(500,title="Take Profit")

sl = input(400,title="Stop Loss")

Up=hl2-(Factor*atr(Pd))

Dn=hl2+(Factor*atr(Pd))

MUp=security(tickerid,res,hl2-(Factor*atr(Pd)))

MDn=security(tickerid,res,hl2+(Factor*atr(Pd)))

Mclose=security(tickerid,res,close)

TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up

TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

MTrendUp=Mclose[1]>MTrendUp[1]? max(MUp,MTrendUp[1]) : MUp

MTrendDown=Mclose[1]<MTrendDown[1]? min(MDn,MTrendDown[1]) : MDn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)

Tsl = Trend==1? TrendUp: TrendDown

MTrend = Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)

MTsl = MTrend==1? MTrendUp: MTrendDown

linecolor = Trend == 1 ? green : red

plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")

Mlinecolor = MTrend == 1 ? blue : orange

plot(MTsl, color = Mlinecolor , style = line , linewidth = 2,title = "Main SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)

plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)

up = Trend == 1 and Trend[1] == -1 and MTrend == 1

down = Trend == -1 and Trend[1] == 1 and MTrend == -1

plotarrow(up ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)

plotarrow(down ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)

golong = Trend == 1 and Trend[1] == -1 and MTrend == 1

goshort = Trend == -1 and Trend[1] == 1 and MTrend == -1

strategy.entry("Sell", strategy.short,when=goshort)

strategy.exit("Close Sell","Sell",profit=tp,loss=sl)

1
Developer 1
2019.08.21
Rating
4.9
(146)
Projects
221
16%
Arbitration
15
40% / 40%
Overdue
33
15%
Working
2
Developer 2
2019.08.21
Rating
4.59
(17)
Projects
16
19%
Arbitration
6
0% / 100%
Overdue
6
38%
Free
3
Developer 3
2019.08.21
Rating
4.8
(97)
Projects
211
36%
Arbitration
52
10% / 69%
Overdue
82
39%
Busy
4
Developer 4
2019.08.21
Rating
4.92
(203)
Projects
334
66%
Arbitration
9
56% / 0%
Overdue
84
25%
Free
5
Developer 5
2019.08.21
Rating
4.56
(9)
Projects
10
40%
Arbitration
1
0% / 100%
Overdue
2
20%
Free
6
Developer 6
2019.08.21
Rating
4.92
(288)
Projects
553
38%
Arbitration
36
14% / 67%
Overdue
114
21%
Working
7
Developer 7
2019.08.26
Rating
4.83
(379)
Projects
677
49%
Arbitration
220
55% / 27%
Overdue
139
21%