Francesco78

Dax survivor long/short mean reverting/breakout

Category: Strategies By: Francesco78 Created: April 29, 2017, 8:36 AM
April 29, 2017, 8:36 AM
Strategies
7 Comments
Dax survivor long/short mean reverting/breakout

Dear all

I have tested a slight variation on the them of my previously described strategy on short TF.

This time I took a very long timeseries, used Daily timeframe and modified the exit strategy in term of number of bars, all is optimized with Reiner’s seasonal parameters

Although the return of 180%  with a drawdown of  ~20k on a such a long timeseries is not great, I though it was worth posting because of the ability of this strategy to survive all the 1998/2001/2008 shocks and because it’s relative smoothness.

Any idea to reduce the drawdown even more would be greatly appreciated.

Best Regards

Francesco

// DAX(mini) - IG MARKETS
// TIME FRAME 1Day
// SPREAD 1.0 Point

DEFPARAM CumulateOrders = False

//DEFPARAM FLATBEFORE =090000
//DEFPARAM FLATAFTER =210000
golong = 1
goshort = 1
exitafternbars =1 // the strategy has an exit strategy of the type n bars

// variables optimized
adxvallong = 36 // set the adx value for long position under which the  strategy is mean reverting and above which the strategy is breakout
atrmaxlong = 100//set the max vol accetable for long position
adxvalshort = 24// set the adx value for short poistions under which the strategy is mean reverting and above which the strategy is breakout
atrmaxshort = 200//set the max vol acceptable for short positions

along= 30//number of cons bar for a long trade
mlong = 1// sets the atr multiplier to enter into a mean reverting strategy for long positions
nlong = 1//sets the atr multiplier to enter into a breakout strategy for long positions

ashort=5//number of cons bars for a short trade
mshort = 1//sets the atr multiplier to enter into a mean reverting strategy for short positions
nshort = 2//sets the atr multiplier to enter into a breakout strategy for short positions
//

vollongok = atr<atrmaxlong
volshortok = atr<atrmaxshort
brekoutlong = marketregimeindicator>adxvallong
meanreversionlong = marketregimeindicator <adxvallong
brekoutshort = marketregimeindicator>adxvalshort
meanreversionshort = marketregimeindicator<adxvalshort
adxperiod = 14
atrperiod = 14
marketregimeindicator = adx[adxperiod]
atr = AverageTrueRange[atrperiod]

positionshort = round(1000/atr) //define the size of short positions
positionlong =  saisonalpatternmultiplier*round(1000/atr/2.16666) // define the size of long positions

// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
ONCE January1 = 3 //0 risk(3)
ONCE January2 = 0 //3 ok
ONCE February1 = 3 //3 ok
ONCE February2 = 3 //0 risk(3)
ONCE March1 = 3 //0 risk(3)
ONCE March2 = 2 //3 ok
ONCE April1 = 3 //3 ok
ONCE April2 = 3 //3 ok
ONCE May1 = 1 //0 risk(1)
ONCE May2 = 1 //0 risk(1)
ONCE June1 = 1 //1 ok 2
ONCE June2 = 2 //3 ok
ONCE July1 = 3 //1 chance
ONCE July2 = 2 //3 ok
ONCE August1 = 2 //1 chance 1
ONCE August2 = 3 //3 ok
ONCE September1 = 3 //0 risk(3)
ONCE September2 = 0 //0 ok
ONCE October1 = 3 //0 risk(3)
ONCE October2 = 2 //3 ok
ONCE November1 = 1 //1 ok
ONCE November2 = 3 //3 ok
ONCE December1 = 3 // 1 chance
ONCE December2 = 2 //3 ok

// set saisonal multiplier
currentDayOfTheMonth = Day
midOfMonth = 15
IF CurrentMonth = 1 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = January1
 ELSE
  saisonalPatternMultiplier = January2
 ENDIF
ELSIF CurrentMonth = 2 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = February1
 ELSE
  saisonalPatternMultiplier = February2
 ENDIF
ELSIF CurrentMonth = 3 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = March1
 ELSE
  saisonalPatternMultiplier = March2
 ENDIF
ELSIF CurrentMonth = 4 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = April1
 ELSE
  saisonalPatternMultiplier = April2
 ENDIF
ELSIF CurrentMonth = 5 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = May1
 ELSE
  saisonalPatternMultiplier = May2
 ENDIF
ELSIF CurrentMonth = 6 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = June1
 ELSE
  saisonalPatternMultiplier = June2
 ENDIF
ELSIF CurrentMonth = 7 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = July1
 ELSE
  saisonalPatternMultiplier = July2
 ENDIF
ELSIF CurrentMonth = 8 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = August1
 ELSE
  saisonalPatternMultiplier = August2
 ENDIF
ELSIF CurrentMonth = 9 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = September1
 ELSE
  saisonalPatternMultiplier = September2
 ENDIF
ELSIF CurrentMonth = 10 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = October1
 ELSE
  saisonalPatternMultiplier = October2
 ENDIF
ELSIF CurrentMonth = 11 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = November1
 ELSE
  saisonalPatternMultiplier = November2
 ENDIF
ELSIF CurrentMonth = 12 THEN
 IF currentDayOfTheMonth <= midOfMonth THEN
  saisonalPatternMultiplier = December1
 ELSE
  saisonalPatternMultiplier = December2
 ENDIF

endif

//long meanreversion
IF (abs(open-close) > (atr*mlong) and close < open and golong and vollongok and meanreversionlong)   THEN
 buy  positionlong CONTRACTS AT MARKET
ENDIF

// long breakout
IF (abs(open-close) > (atr*nlong) and close > open and golong and vollongok and brekoutlong)   THEN
 buy  positionlong CONTRACTS AT MARKET
ENDIF

//short meanrevesrion
IF (abs(open-close) > (atr*mshort) and close > open and goshort and volshortok and meanreversionshort)   THEN
 sellshort positionshort CONTRACTS AT MARKET
ENDIF

// short
IF (abs(open-close) > (atr*nshort) and close < open and goshort and volshortok and brekoutshort)   THEN
 sellshort  positionshort CONTRACTS AT MARKET
ENDIF

if exitafternbars then
 IF shortonmarket and BarIndex - TradeIndex >= ashort Then
  exitshort  positionshort contracts at Market
 EndIF
endif

if exitafternbars then
 IF longonmarket and BarIndex - TradeIndex >= along Then
  sell  positionlong contracts at Market
 EndIF
endif

//set target profit p*atr
//set stop ploss l*atr

 

Download
Filename: Dax1Dsurvivor_v2.itf
Downloads: 322
Download
Filename: daxsurvivor_2.png
Downloads: 237
Download
Filename: Dax1DMNandBreak.itf
Downloads: 323
Download
Filename: statdax1d.png
Downloads: 185
Francesco78
Francesco78 Master
Operating in the shadows, I hack problems one by one. My bio is currently encrypted by a complex algorithm. Decryption underway...
Author’s Profile

Comments

Khaled
6 years ago
#

Hi Francesco , thank you for sharing your hard work. Any idea why all orders are executed at 01.00 am (French/Italian time)? Thanks Khaled

Francesco78
9 years ago
#

I did a little bit of work on that and now the results looks better and more stable.

Please let me know what you think!

// DAX(mini) - IG MARKETS
// TIME FRAME 1Day
// SPREAD 1.0 Point

DEFPARAM CumulateOrders = False

//DEFPARAM FLATBEFORE =090000
//DEFPARAM FLATAFTER =210000
golong = 1
goshort = 1
exitafternbars =1 // the strategy has an exit strategy of the type n bars


// variables optimized
adxvallong = 28 // set the adx value for long position under which the  strategy is mean reverting and above which the strategy is breakout
atrmaxlong = 250//set the max vol accetable for long position
adxvalshort = 20// set the adx value for short poistions under which the strategy is mean reverting and above which the strategy is breakout
atrmaxshort = 250//set the max vol acceptable for short positions

along= 30//number of cons bar for a long trade
mlong = 1// sets the atr multiplier to enter into a mean reverting strategy for long positions
nlong = 1.2//sets the atr multiplier to enter into a breakout strategy for long positions

ashort=7//number of cons bars for a short trade
mshort = 1//sets the atr multiplier to enter into a mean reverting strategy for short positions
nshort = 2//sets the atr multiplier to enter into a breakout strategy for short positions
//

vollongok = atr<atrmaxlong
volshortok = atr<atrmaxshort
brekoutlong = marketregimeindicator>adxvallong
meanreversionlong = marketregimeindicator <adxvallong
brekoutshort = marketregimeindicator>adxvalshort
meanreversionshort = marketregimeindicator<adxvalshort
adxperiod = 17
atrperiod = 13
marketregimeindicator = adx[adxperiod]
atr = AverageTrueRange[atrperiod]

positionshort = round(1000/atr) //define the size of short positions
positionlong =  saisonalpatternmultiplier*round(1000/atr/2.16666) // define the size of long positions


// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
ONCE January1 = -3//3 //0 risk(3)
ONCE January2 = 2//0 //3 ok
ONCE February1 = 3 //3 ok
ONCE February2 = -3//3 //0 risk(3)
ONCE March1 = 0//3 //0 risk(3)
ONCE March2 = 3//2 //3 ok
ONCE April1 = 3 //3 ok
ONCE April2 = 3 //3 ok
ONCE May1 = 3//1 //0 risk(1)
ONCE May2 = 1 //0 risk(1)
ONCE June1 = -2//1 //1 ok 2
ONCE June2 = 3//2 //3 ok
ONCE July1 = -2//3 //1 chance
ONCE July2 = 1 //3 ok
ONCE August1 = 3 //1 chance 1
ONCE August2 = 3 //3 ok
ONCE September1 = 2//3 //0 risk(3)
ONCE September2 = 0 //0 ok
ONCE October1 = 3 //0 risk(3)
ONCE October2 = 3//2 //3 ok
ONCE November1 =3// 1 //1 ok
ONCE November2 = 3 //3 ok
ONCE December1 = 3 // 1 chance
ONCE December2 = 3//2 //3 ok

// set saisonal multiplier
currentDayOfTheMonth = Day
midOfMonth = 15
IF CurrentMonth = 1 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = January1
ELSE
saisonalPatternMultiplier = January2
ENDIF
ELSIF CurrentMonth = 2 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = February1
ELSE
saisonalPatternMultiplier = February2
ENDIF
ELSIF CurrentMonth = 3 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = March1
ELSE
saisonalPatternMultiplier = March2
ENDIF
ELSIF CurrentMonth = 4 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = April1
ELSE
saisonalPatternMultiplier = April2
ENDIF
ELSIF CurrentMonth = 5 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = May1
ELSE
saisonalPatternMultiplier = May2
ENDIF
ELSIF CurrentMonth = 6 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = June1
ELSE
saisonalPatternMultiplier = June2
ENDIF
ELSIF CurrentMonth = 7 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = July1
ELSE
saisonalPatternMultiplier = July2
ENDIF
ELSIF CurrentMonth = 8 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = August1
ELSE
saisonalPatternMultiplier = August2
ENDIF
ELSIF CurrentMonth = 9 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = September1
ELSE
saisonalPatternMultiplier = September2
ENDIF
ELSIF CurrentMonth = 10 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = October1
ELSE
saisonalPatternMultiplier = October2
ENDIF
ELSIF CurrentMonth = 11 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = November1
ELSE
saisonalPatternMultiplier = November2
ENDIF
ELSIF CurrentMonth = 12 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = December1
ELSE
saisonalPatternMultiplier = December2
ENDIF

endif




//long meanreversion
IF (abs(open-close) > (atr*mlong) and close < open and golong and vollongok and meanreversionlong)   THEN
buy  positionlong CONTRACTS AT MARKET
ENDIF


// long breakout
IF (abs(open-close) > (atr*nlong) and close > open and golong and vollongok and brekoutlong)   THEN
buy  positionlong CONTRACTS AT MARKET
ENDIF


//short meanrevesrion
IF (abs(open-close) > (atr*mshort) and close > open and goshort and volshortok and meanreversionshort)   THEN
sellshort positionshort CONTRACTS AT MARKET
ENDIF

// short
IF (abs(open-close) > (atr*nshort) and close < open and goshort and volshortok and brekoutshort)   THEN
sellshort  positionshort CONTRACTS AT MARKET
ENDIF



if exitafternbars then
IF shortonmarket and BarIndex - TradeIndex >= ashort Then
exitshort  positionshort contracts at Market
EndIF
endif

if exitafternbars then
IF longonmarket and BarIndex - TradeIndex >= along Then
sell  positionlong contracts at Market
EndIF
endif

p = 6
l = 7

set target profit p*atr
set stop ploss l*atr

Regards

Francesco 

Francesco78
9 years ago
#

I did a little bit of work on that and now the results looks better and more stable.

Please let me know what you think!

Regards

Francesco 

Francesco78
9 years ago
#

Hi Keemax, I dont have it on real at the moment, in any case the strategy is very long term and dont generate a big number of trade so it is reasonable that you dont have any signal if you put it just for few days, I suggest to do a backtesting starting from the day you you have chosen to put in on real and see if there is a discrepancy from back test and real.

I hope that helps.

Francesco 

keemax73
9 years ago
#

Ciao Francesco78, i tried to put your strategy in real mode but did not generate any movement.

What am I doing wrong ?

Thank you.

Francesco78
9 years ago
#

Hi Cosmic1

Thank you for your comments.

what I did is to optimize the code for different time frames, we could optimized in order for the strategy to work for the last 2 years or 5 years, but in my opinion by doing so we will get an insufficient number of trades in order to make the sample statistically significative.

From what I remember I agree with you, if you do WF from the beginning of the time series then the last period is flat or slightly negative, if instead you make the optimization starting from more recent time, i.e. 2007 in that case you get an upward slope.

Id be happy to discuss further.

Best Regards

Francesco 

 

Cosmic1
9 years ago
#

Hi Francesco, thanks for your hard work. I have been playing around with your strategy but can't get an IN/OUT /WF sample to work. The best I can get is either a slight decline, flat or very slight profit on the out sample for the last period and no where near 50% efficiency. Did you test in this way, what are your views?

ProRealCode ProRealCode
Loading...