Arctan EA

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

Arctan EA

Postby EZB-Schmarotzer » Mon Mar 30, 2020 8:57 pm

Good morning Sir,

could you translate the following code from ProRealtime language into MQL4?

Thanks a lot in advance!


--------------------------------------------


// ROBOT Arctan


DEFPARAM CumulateOrders = false


//VARIABLES
CtimeA = time >= 080000 and time <= 220000
CtimeB = time >= 080000 and time <= 220000
ONCE BarLong = 950 //EXIT ZOMBIE TRADE LONG
ONCE BarShort = 650 //EXIT ZOMBIE TRADE SHORT

// TAILLE DES POSITIONS
ONCE PositionSizeLong = 1
ONCE PositionSizeShort = 2


//STRATEGIE

//VECTEUR = CALCUL DE L'ANGLE
ONCE PeriodeA = 10
ONCE nbChandelierA= 15
MMA = Exponentialaverage[PeriodeA](close)
ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA
ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE
CondBuy1 = ANGLE >= 45
CondSell1 = ANGLE <= - 37


//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE
ONCE PeriodeB = 20
ONCE nbChandelierB= 35
lag = 5
MMB = Exponentialaverage[PeriodeB](close)
pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB
trigger = Exponentialaverage[PeriodeB+lag](pente)
CondBuy2 = (pente > trigger) AND (pente < 0)
CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)



//ENTREES EN POSITION
CONDBUY = CondBuy1 and CondBuy2 and CTimeA
CONDSELL = CondSell1 and CondSell2 and CtimeB


//POSITION LONGUE
IF CONDBUY THEN
buy PositionSizeLong contract at market
SET TARGET %PROFIT 4.25
ENDIF

//POSITION COURTE
IF CONDSELL THEN
Sellshort PositionSizeShort contract at market
SET TARGET %PROFIT 1.25
ENDIF

//VARIABLES STOP SUIVEUR
ONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ON
ONCE trailingstoplong = 7.5 // Trailing Stop Atr Relative Distance
ONCE trailingstopshort = 4 // Trailing Stop Atr Relative Distance

ONCE atrtrailingperiod = 25 // Atr parameter Value
ONCE minstop = 0 // Minimum Trailing Stop Distance


// TRAILINGSTOP
//----------------------------------------------
atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstartS = round(atrtrail*trailingstopshort)
if trailingStopType = 1 THEN
TGL =trailingstartl
TGS=trailingstarts
if not onmarket then

MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
if MAXPRICE-tradeprice(1)>=MINSTOP then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ELSE
PREZZOUSCITA = MAXPRICE - MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
if tradeprice(1)-MINPRICE>=MINSTOP then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ELSE
PREZZOUSCITA = MINPRICE + MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
ENDIF

//EXIT ZOMBIE TRADE
IF POSITIONPERF<0 THEN
IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
EXITSHORT AT MARKET
ENDIF
ENDIF

IF POSITIONPERF<0 THEN
IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barlong THEN
SELL AT MARKET
ENDIF
ENDIF
EZB-Schmarotzer
 
Posts: 25
Joined: Mon Oct 28, 2019 10:00 am

Re: Arctan EA

Postby Apprentice » Tue Mar 31, 2020 5:20 am

Your request is added to the development list.
Development reference 975.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Arctan EA

Postby Apprentice » Wed Apr 01, 2020 8:32 am

Try this version.
viewtopic.php?f=38&t=69603

I think the code provided is incorrect. It'll never trade according to the formula
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
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 26 guests