//————————————————————————-
// Main code : Vectorial DJI 3M v6.0 +entFilt
//————————————————————————-
//————————————————————————-
// Main code : Vectorial DJI 3M v6.0
//————————————————————————-
//————————————————————————-
// Main code : _Vectorial Dax V3
//————————————————————————-
// ROBOT VECTORIAL DAX
// M5
// SPREAD 1.5
// by BALMORA 74 – FEBRUARY 2019
DEFPARAM CumulateOrders = false
DEFPARAM Preloadbars = 50000
T1 = 6
p1 = average[t1](close)
p2 = average[t1*2](close)
p3 = average[t1*6](close)
p4 = average[t1*3](close)
a1 = p1 > p2 and p2 > p3 and p3 > p4
a2 = p1 < p2 and p2 < p3 and p3 < p4
//VARIABLES
CtimeA = time >= 080000 and time <= 180000
CtimeB = time >= 080000 and time <= 180000
// TAILLE DES POSITIONS
PositionSizeLong = 1
PositionSizeShort = 1
//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 >= 35
CondSell1 = ANGLE <= – 40
//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE
ONCE PeriodeB = 20
ONCE nbChandelierB= 35
lag = 1.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 and A1 THEN
buy PositionSizeLong contract at market
//SET Target %PROFIT 1
//SET STOP %LOSS 0.7
ENDIF
//POSITION COURTE
IF CONDSELL and a2 THEN
Sellshort PositionSizeShort contract at market
//SET Target %PROFIT 1.2
//SET STOP %LOSS 1
ENDIF
//VARIABLES STOP SUIVEUR
ONCE trailingStopType = 1 // Trailing Stop – 0 OFF, 1 ON
ONCE trailingstoplong = 9 // Trailing Stop Atr Relative Distance
ONCE trailingstopshort = 8 // Trailing Stop Atr Relative Distance
ONCE atrtrailingperiod = 14 // 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