CAD-Hunter

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

CAD-Hunter

Postby EZB-Schmarotzer » Thu Oct 31, 2019 9:07 am

Dear Sir,

as I saw you developing more complex EAs as the Ichimoku today, I'd like to ask whether you could translate the following code from ProRealtime into an MT4 Expert Advisor.

It's a bit more complicated than the codes before, however I am sure, that you will make it :)



Here's the code
---------------------------------------------

Defparam CumulateOrders=false



Once period=8 //Please add as a variable
Once smooth =13 //Please add as a variable
Once minmaxperiod=25 //Please add as a variable
Once uplevel=90 //Please add as a variable
Once downlevel=10 //Please add as a variable

if barindex>period+minmaxPeriod then

noise = 0
vhf = 0
mmax = Close[0]
mmin = Close[0]
for k=0 to period-1 do
noise = noise+Abs(Close[k]-Close[k+1])
mmax = Max(Close[k],mmax)
mmin = Min(Close[k],mmin)
next
if (noise>0) then
vhf = (mmax-mmin)/noise
endif
tperiod = period
fzPeriod = minmaxPeriod

if (vhf>0) then
tperiod = -Log(vhf)*period
fzPeriod = round(Max(-Log(vhf)*minmaxPeriod,3))
endif
alpha = 2.0/(tperiod+1.0)

//ISSM settings
Pi = 3.14159265358979323846264338327950288
a1 = Exp(-1.414*Pi/Smooth)
b1 = 2.0*a1*Cos(1.414*Pi/Smooth)
sc2 = b1
sc3 = -a1*a1
sc1 = 1.0 - sc2 - sc3
//Exponential Smoothing and Innovation State Space Model (ISSM)
tprice = High
workSsm01 = tprice
if barindex>1 then
workSsm11 = sc1*(workSsm01+workSsm01[1])/2.0 + sc2*workSsm11[1] + sc3*workSsm11[2]
else
workSsm11 = tprice
endif
hc = workSsm11
//Exponential Smoothing and Innovation State Space Model (ISSM)
tprice = Low
workSsm02 = tprice
if barindex>1 then
workSsm12 = sc1*(workSsm02+workSsm02[1])/2.0 + sc2*workSsm12[1] + sc3*workSsm12[2]
else
workSsm12 = tprice
endif
lc = workSsm12
//Exponential Smoothing and Innovation State Space Model (ISSM)
tprice = Close[1]
workSsm03 = tprice
if barindex>1 then
workSsm13 = sc1*(workSsm03+workSsm03[1])/2.0 + sc2*workSsm13[1] + sc3*workSsm13[2]
else
workSsm13 = tprice
endif
cp = workSsm13
//Exponential Smoothing and Innovation State Space Model (ISSM)
tprice = High[1]
workSsm04 = tprice
if barindex>1 then
workSsm14 = sc1*(workSsm04+workSsm04[1])/2.0 + sc2*workSsm14[1] + sc3*workSsm14[2]
else
workSsm14 = tprice
endif
hp = workSsm14
//Exponential Smoothing and Innovation State Space Model (ISSM)
tprice = Low[1]
workSsm05 = tprice
if barindex>1 then
workSsm15 = sc1*(workSsm05+workSsm05[1])/2.0 + sc2*workSsm15[1] + sc3*workSsm15[2]
else
workSsm15 = tprice
endif
lp = workSsm15
dh = Max(hc-hp,0)
dl = Max(lp-lc,0)

if(dh=dl) then
dh=0
dl=0
elsif(dh<dl) then
dh=0
elsif(dl<dh) then
dl=0
endif

ttr = Max(hc,cp)-Min(lc,cp)
dhk = 0
dlk = 0

if(ttr<>0) then
dhk = 100.0*dh/ttr
dlk = 100.0*dl/ttr
endif

workzdh = workzdh[1] + alpha*(dhk-workzdh[1])
workzdl = workzdl[1] + alpha*(dlk-workzdl[1])
dDI = workzdh - workzdl

div = Abs(workzdh + workzdl)
temp = 0
if( div <> 0.0) then
temp = 100*dDI/div
endif

aADX = aADX[1]+alpha*(temp-aADX[1])
//floating levels
//flLookBack = MinMaxPeriod // Floating levels lookback period
flLevelUp = upLevel // Floating levels up level %
flLevelDown = downLevel // Floating levels down level %
maxi = highest[fzperiod](aadx)
mini = lowest[fzperiod](aadx)
rrange = maxi-mini
flu = mini+flLevelUp*rrange/100.0
fld = mini+flLevelDown*rrange/100.0


endif

If aadx crosses over flu then
buy 1 shares at market
endif

If aadx crosses under fld then
sellshort 1 shares at market
endif
EZB-Schmarotzer
 
Posts: 17
Joined: Mon Oct 28, 2019 10:00 am

Re: CAD-Hunter

Postby Apprentice » Fri Nov 01, 2019 7:16 am

Your request is added to the development list.
Development reference 270.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 23173
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 10 guests