Dear Sir,
could you please convert the following code from ProRealtime into an MT4 expert advisor?
---------------------
defparam cumulateorders = false
// parameters
HalfLength = 141 //please add this as a variable
AtrLength = 141 //please add this as a variable
AtrMultiplier = 2.4 //please add this as a variable
avg = average [1](close)
sum = (HalfLength+1)*avg
sumw = (HalfLength+1)
k = HalfLength
for j = 1 to HalfLength do
k = k-1
sum = sum+(k*avg[j])
sumw = sumw+k
next
myrange = AverageTrueRange[AtrLength](close)*AtrMultiplier
middleband = sum/sumw
//higherband = buffer1+myrange
lowerband = middleband-myrange
upperband = middleband+myrange
TradingDay = opendayofweek = 1 or dayofweek = 2 or dayofweek = 3 or dayofweek = 4 or dayofweek = 5
IF TradingDay then
if average [1] (close) crosses over lowerband then
buy at market
endif
Endif
if average [1] (close) crosses over middleband then
sell at market
endif
IF TradingDay then
if average [1] (close) crosses under upperband then
sellshort at market
endif
Endif
if average [1] (close) crosses under middleband then
exitshort at market
endif
set stop %loss 3
set target %profit 3 // as insurance