Balmora74

VECTORIAL DAX (M5)

Category: Strategies By: Balmora74 Created: February 24, 2019, 8:54 AM
February 24, 2019, 8:54 AM
Strategies
22 Comments
VECTORIAL DAX (M5)

Hello. I share with the community an automatic strategy that works on the DAX for M5 timeframe.

I wanted to test a strategy that involves observing the angular orientation of a moving average. The higher the angle and slope of the moving average, the stronger and more directional the movement. It then took me back into my distant memories of mathematics courses, trigonometry and vector calculus to try to develop this code.

The strategy consists first of all in calculating the angular orientation of a 10-period moving average (PeriodA) over a period of 15 bars (nbChandelierA). Then I calculate the slope of this moving average. This amounts to calculating a “vector” hence the name of the algorithm.

I then added a trailing stop and optimized the entry points with particular playing on the variable “lag”.

I launched the code in real mode and in demo mode. There are some differences in the positions, but overall it works pretty well.

Note that the attached backtest images correspond to a backtest on 200,000 bars (Premium version of PRT) with a spread of 1.5 points.

The code looks good on other timeframes (including H4) by changing the variables.

Looking forward to having your feedback, feedback and suggestions for improvements.

 

// ROBOT VECTORIAL DAX
// M5
// SPREAD 1.5
// by BALMORA 74 - FEBRUARY 2019

DEFPARAM CumulateOrders = false
DEFPARAM Preloadbars = 50000


//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

Download
Filename: capture-decran-1550926577pl4c8.png
Downloads: 318
Download
Filename: Vectorial-DAX-M5-1.itf
Downloads: 2042
Download
Filename: Capture-décran-2019-02-23-13.30.19-1.png
Downloads: 529
Download
Filename: Capture-décran-2019-02-23-13.30.07-1.png
Downloads: 482
Download
Filename: Capture-décran-2019-02-23-13.29.46-1.png
Downloads: 1113
Download
Filename: Capture-décran-2019-02-23-13.29.28-1.png
Downloads: 281
Download
Filename: Capture-décran-2019-02-23-13.29.28.png
Downloads: 602
Balmora74
Balmora74 Veteran
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

#

hola buenas, a este sistema automático, Cómo se le podría poner un stoploss de beneficio simple. sin alterar el sistema entero. Gracias.

antonio73
6 years ago
#

Balmora74, io vedo che funziona anche su timeframe ad 1 minuto con piccole ottimizzazioni, tu che ne pensi?

Tony87
7 years ago
#

can we have a update on this one please?

Nicolas
7 years ago
#

Discussions with many other versions and improvements can be found here: https://www.prorealcode.com/topic/vectorial-dax-m5/

rrenaud_ig
7 years ago
#

Great work ! My only concern is about risk management. Your results are based on 10k. Max loss 500euro. Its mean 5% max loss by trade. Ratio Risk-Reward is approx. 1:1. My problem with that is consecutive lost that can ruine you in a losing strike. Have you try to play with ratio RR and max loss by trade ?

kompiuter
7 years ago
#

Hello, how did you optimized all these variable? If I try to optimize only two variables it takes hours and often the software crashes. Thanks in advance and compliment for this algorithm! Marco

sharksteven
7 years ago
#

Hi BALMORA, looks like a good compliment algorithm. I tried to test it on the EUR USD but it doesn't calculate any trade, how come?

PacoLopez
7 years ago
#

Thanks Balmora74. 100% clear now. Not posible at all with IB Only option by now with IG Thanks Regards Paco

Balmora74
7 years ago
#

@Pacolopez Hi ! I run this code live on IG CFDs (not via IG Interactive Broker).

darbes
6 years ago
#

Hi How does it go on live ? JC

PacoLopez
7 years ago
#

Hello Balmora, good morning. Nice code, Thanks for sharing. I just read from your comments that you are using this strategy in live and demo. I am just asking how to move this code to live. As far as I know with ProRealTime and IB (interactive Broker) you can not use ProOrder Automatic trading. You can only use this with IG CFDs... I have some codes in demo and I would like to move forward to live. Any help I will apreciate. Thanks a lot Regards Paco

Balmora74
7 years ago
#

@Pacolopez read this : https://www.prorealcode.com/topic/main-differences-prorealtime-software-prorealtime-ib-and-prorealtime-ig/

Dymjohn
8 years ago
#

Great work I've changed the trade quantity to reflect whether price is above or below the 200 day moving average a "buy" of 2 if above this average and a sell of 1 and for a "sell" of 2 if below the average and 1 if above. Makes little difference on the most recent 100000 units but I think gives better logic in the light of current trend.

Balmora74
8 years ago
#

Hi Jerke and thanks for your return. I choose the values because they gave me the best equity curve... But i will try to test the strategy with the same values for couples in A and B...

JvdG
8 years ago
#

Hi, nice piece of work, using atan. My question: MMA is constituted by the 10 most recent bars (PeriodeA=10). Why not also assign nbChandelierA with the same value 10? That would make your algo more consistent. The same goes for the couple in ~B. Regards, Jerke

superborstig
8 years ago
#

Hallo Balmora74, you wrote: "The code looks good on other timeframes (including H4) by changing the variables." How do you change the variables on which timeframes?

Balmora74
8 years ago
#

Hello Superborstig. Fore more info : https://www.prorealcode.com/topic/vectorial-dax-m5/

JohnCato
8 years ago
#

Thanks for sharing that Balmora. Nice work.

Balmora74
8 years ago
#

Link to the forum : https://www.prorealcode.com/topic/vectorial-dax-m5/

Balmora74
8 years ago
#

Not yet but i'll try to do it. Is it possible to open a file discussion in the French or English forum in order to share ideas and trying to improve this strategy ?

Nicolas
8 years ago
#

English topic should drain more people!

Nicolas
8 years ago
#

Thanks for this contribution to our library! Did you try Out Of Sample (OOS) tests after optimization? or even in backtest by optimizing only a single part of the history?

ProRealCode ProRealCode
Loading...