Dax adaptable strategy Breackout/Mean reversion
Forums › ProRealTime English forum › ProOrder support › Dax adaptable strategy Breackout/Mean reversion
- This topic has 82 replies, 13 voices, and was last updated 3 years ago by xburrex.
-
-
05/15/2017 at 12:03 AM #3551905/15/2017 at 12:09 AM #35520
Thanks a lot Noisette, what do you mean by max size for stop loss?
05/15/2017 at 7:51 AM #3553105/15/2017 at 9:24 AM #3554805/15/2017 at 11:27 AM #35569Hi Nicolas,
yes unfortunatley there are a few variables.
I can suggest this variable ranges:
ADXVAL [18:28, 2]
M,N,M1,N1 = [1:4,1]
k,y [3:10,1]
atrmin :[15:40,5]
timestart and timeend I think can be optimized later, they dont have a big impact.
Hope this help
05/15/2017 at 4:12 PM #35610@Francesco78 sorry for taking so long to respond, been very busy with work!
Yes I’ve been running the 30 min and 1hr on my live account and had good results, although I have to admit that I tend to close positions manually when they show a good profit… Although I also run the same systems on my demo account too.
As for the optimisation are those variables you posted recently the ones to optimise for? I am just trying to understand the logic of the system so I can play around with it, once the volatility has been determined does it simply enter at a multiple of the ATR? What made you think to try a system such as this?
Once again thanks a lot and great work! 🙂
05/15/2017 at 11:50 PM #35656Here the modified code:
- Different values morning vs afternoon
- Maximum value for stop loss
- Positions can be stopped later (20h instead of 17h30)
I think that we can add trailing stop (Nicolas code) to improve this code.
Regards.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485// dax - IG MARKETS// TIME FRAME 30min// SPREAD 1.0 PIPSDEFPARAM CumulateOrders = FalseDEFPARAM FLATBEFORE = 070000DEFPARAM FLATAFTER = 200000ONCE POSITION =1timestart = 080000timeend = 173000timeenterbefore = time <= timeendtimeenterafter = time >= timestart//highvolume = average[30](volume)<=volume////lowvolume = average[30](volume)>=volumeadxperiod =15//15atrperiod = 17//17indicator1 = adx[adxperiod]atr = AverageTrueRange[atrperiod]//exitafternbars = 1//// OPTIMIZED VARIABLES/////K = 8 //8Y = 3 //5MAXPL = 80AFTERNOON = 143000IF TIME < AFTERNOON THENadxval = AA//20//20atrmin = BB//27//19m = 3 // high vol coefficient for mean reversionn = 2 //high vol coefficient for breakoutZ = 1 //1.4ELSEadxval = CC//26//20atrmin = DD//22//19m = 3 // high vol coefficient for mean reversionn = 2 //high vol coefficient for breakoutZ = 1 //0.8ENDIFm1 = m- Z //1 // low vol coefficient for mean reversionn1 = n// low vol coefficient for breakoutpr = K*atrpl = Y*atrIF PL > MAXPL THENPLL = MAXPLELSEPLL = PLENDIF///////////////////////////////////////lowvolenvironment = atr<atrmin //define lowvol environment use m1 and n1 as coefficient of movementhighvolenvironment = atr> atrmin //define highvol environment use m and n as coefficient of movementmeanrevertingenv = indicator1< adxval //define meanreverting environmenttrendenv = indicator1 > adxval// define trendy environment//////description of the possible combinationssellhighvolmeanreverting = abs(open-close) > (atr*m) and close > open and meanrevertingenv and highvolenvironmentbuyhighvolmeanreverting = abs(open-close) > (atr*m) and close < open and meanrevertingenv and highvolenvironmentbuyhighvoltrendy = abs(open-close) > (atr*n) and close > open and close> DOPEN(1) and trendenv and highvolenvironmentsellhighvoltrendy = abs(open-close) > (atr*n) and close < open and close< DOPEN(1) and trendenv and highvolenvironmentselllowvolmeanreverting = abs(open-close) > (atr*m1) and close > open and meanrevertingenv and lowvolenvironmentbuylowvolmeanreverting = abs(open-close) > (atr*m1) and close < open and meanrevertingenv and lowvolenvironmentbuylowvoltrendy = abs(open-close) > (atr*n1) and close > open and trendenv and lowvolenvironmentselllowvoltrendy = abs(open-close) > (atr*n1) and close < open and trendenv and lowvolenvironment//////////////////////////////////////////////////////////longIF (buyhighvolmeanreverting or buyhighvoltrendy or buylowvolmeanreverting or buylowvoltrendy ) and timeenterbefore and timeenterafter THENbuy POSITION CONTRACTS AT MARKETENDIF// shortIF (sellhighvolmeanreverting or sellhighvoltrendy or selllowvolmeanreverting or selllowvoltrendy) and timeenterbefore and timeenterafter THENsellshort POSITION CONTRACTS AT MARKETENDIFIF TIME > TIMEEND AND LONGONMARKET AND (sellhighvolmeanreverting or sellhighvoltrendy or selllowvolmeanreverting or selllowvoltrendy) THENSELL AT MARKETENDIFIF TIME > TIMEEND AND SHORTONMARKET AND (buyhighvolmeanreverting or buyhighvoltrendy or buylowvolmeanreverting or buylowvoltrendy ) THENEXITSHORT AT MARKETENDIF05/16/2017 at 7:42 AM #35665I ran a 5 iterations Walk Forward analysis yesterday (on 100k bars only) with the variables ranges you gave me (for the 30 minutes version), PFA the results. Even if the equity curve is not steady, the WF study is not so “critical”. Remember that in its current state, the WF tool only give the result of the most profitable OOS settings at the end, it doesn’t mean that other settings wouldn’t have made a more “steady” curve..
05/16/2017 at 7:47 AM #35669Thank you very much Noisette will have a look this afternoon.
Thanks Nicolas for your time spent on the code. Just for my info can you tell me which version of the code you used for the wf? Thanks again
05/16/2017 at 8:39 AM #35671I used this one:
fixed lot+variables names modified1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374// dax - IG MARKETS// TIME FRAME 30min// SPREAD 1.0 PIPSDEFPARAM CumulateOrders = Falsetimestart = 080000timeend = 200000timeenterbefore = time <= timeendtimeenterafter = time >= timestartadxperiod = 14atrperiod = 14myADX = adx[adxperiod]atr = AverageTrueRange[atrperiod]//// OPTIMIZED VARIABLES/////profitCoeff = 8lossCoeff = 5myprofit = profitCoeff*atrmyloss = lossCoeff*atr//adxval = 20//atrmin = 19m = 3 // high vol coefficient for mean reversionn = 2 //high vol coefficient for breakoutm1 = m-1 // low vol coefficient for mean reversionn1 = n // low vol coefficient for breakout///////////////////////////////////////positionlong = 1 // define sixe of long tradespositionshort = 1 // define size of short tradelowvolenvironment = atr < atrmin //define lowvol environment use m1 and n1 as coefficient of movementhighvolenvironment = atr > atrmin //define highvol environment use m and n as coefficient of movementmeanrevertingenv = myADX < adxval //define meanreverting environmenttrendenv = myADX > adxval // define trendy environment//////description of the possible combinations//mean revertingsellhighvolmeanreverting = abs(open-close) > (atr*m) and close > open and meanrevertingenv and highvolenvironmentbuyhighvolmeanreverting = abs(open-close) > (atr*m) and close < open and meanrevertingenv and highvolenvironmentselllowvolmeanreverting = abs(open-close) > (atr*m1) and close > open and meanrevertingenv and lowvolenvironmentbuylowvolmeanreverting = abs(open-close) > (atr*m1) and close < open and meanrevertingenv and lowvolenvironment//trend followingbuyhighvoltrendy = abs(open-close) > (atr*n) and close > open and close> DOPEN(1) and trendenv and highvolenvironmentsellhighvoltrendy = abs(open-close) > (atr*n) and close < open and close< DOPEN(1) and trendenv and highvolenvironmentbuylowvoltrendy = abs(open-close) > (atr*n1) and close > open and trendenv and lowvolenvironmentselllowvoltrendy = abs(open-close) > (atr*n1) and close < open and trendenv and lowvolenvironment//////////////////////////////////////////////////////////longIF (buyhighvolmeanreverting or buyhighvoltrendy or buylowvolmeanreverting or buylowvoltrendy ) and timeenterbefore and timeenterafter THENbuy positionlong CONTRACTS AT MARKETENDIFif longonmarket and time = timeend thensell at marketendif// shortIF (sellhighvolmeanreverting or sellhighvoltrendy or selllowvolmeanreverting or selllowvoltrendy) and timeenterbefore and timeenterafter THENsellshort positionshort CONTRACTS AT MARKETendifif shortonmarket and time = timeend thenexitshort at marketendifset target pprofit myprofitset stop ploss myloss05/16/2017 at 11:49 AM #35697Noisette, I cant run it, can you make a version with only the relevant variables?
THanks a lot
05/16/2017 at 12:21 PM #3570005/16/2017 at 8:14 PM #3574505/16/2017 at 8:30 PM #3574805/18/2017 at 11:34 AM #35977Sorry for the late reply.
As for the optimisation are those variables you posted recently the ones to optimise for?
yes that’s correct
I am just trying to understand the logic of the system so I can play around with it, once the volatility has been determined does it simply enter at a multiple of the ATR?
yes that’s correct, ATR is the measure of volatility that I like to use in my codes
What made you think to try a system such as this?
Honestly in this case is just logic, I wanted to create a system that could work on both mean reverting and trendy market so I just split my scenario in 2 parts depending on the ADX indicator that measure the trendiness of the market. As far as the ATR, I think in general it is very useful to smoothen the curve when you define your position size as inverse function of the ATR, so the system will automatically reduce the position in case of high volatility and viceversa.
-
AuthorPosts
Find exclusive trading pro-tools on