Dax adaptable strategy Breackout/Mean reversion

Viewing 15 posts - 61 through 75 (of 83 total)
  • Author
    Posts
  • #37185 quote
    noisette
    Participant
    Veteran

    Hello,

    I didn’t saw before but short positions are more profitable than long positions. Do you find same results?

    I tried to add stoploss at breakeven but results are not much better.

    Good point is that demo and backtest results are more or less the same.

    I’ll try to code automatic closing position after x candles because i have the impression that most of the point are win during the first candles.

    Regards.

    #37367 quote
    kg6450
    Participant
    Average

    Hi Noisette, I also found that the results for the backtest and live are more or less the same too. Also short positions tend to be more profitable too.

    Have you tried to optimise this strategy for other markets? I have tried with little success so far

    Francesco78 thanked this post
    #37396 quote
    noisette
    Participant
    Veteran

    Hi kg6450 ,

    I didn’t try so far with other markets. It could be interesting with CAC to have lower leverage.

    But because DAX is nervous compare with CAC, it is probably difficult to find same result.

    I also should try to find wich of the conditions are the more profitable.

    Regards.

    I also try M15 timeframe but not good so far.

    Francesco78 thanked this post
    #37404 quote
    Francesco78
    Participant
    Master

    Thanks a lot Noisette and kg6450, I have tried with other markets too and I find something more or less nice with EUR/USD, but not as good as with DAX 30mina nd Dax 1hr

    #37539 quote
    kg6450
    Participant
    Average

    I have tried to optimise it for BUND, FTSE and the S&P500 on the 1hr timeframe and while they all end in profit, none of the strategies are feasible enough to run over the long term.

    I am running the optimiser for the original version of the DAX1hrMNandBK strategy that you posted earlier, is that the correct one?

    I will test a few more markets today too

    #37548 quote
    Francesco78
    Participant
    Master

    Hi kg6450, yes, that’s the one, many thanks for your help!

    #37607 quote
    kg6450
    Participant
    Average

    That’s ok!

    I just finished the DOW; with a single position it is showing profit but the drawdown is still too high for some of them (about 1/3 of the profit)

    Do you have any suggestions for reducing the drawdown?

    #37622 quote
    Francesco78
    Participant
    Master

    kg 6450, you can try by adding seasonality parameters pathfinder style if the strategy is good enough without.

    on  the dax I did try it and this is the code, you could try to do the same for the dow hopefully you will get a nicer result.

    //-------------------------------------------------------------------------
    // Main code : Dax1hrMNandBreakwithseas
    //-------------------------------------------------------------------------
    // dax  - IG MARKETS
    // TIME FRAME 1H
    // SPREAD 1.0 PIPS
    
    
    
    DEFPARAM CumulateOrders = False
    
    
    //DEFPARAM FLATBEFORE = 090000
    //DEFPARAM FLATAFTER = 210000
    
    
    timestart = 070000
    timeend = 200000
    
    timeenterbefore = time <= timeend
    timeenterafter =  time >= timestart
    
    
    //highvolume = average[30](volume)<=volume//
    //lowvolume = average[30](volume)>=volume
    
    adxperiod = 14
    atrperiod = 14
    indicator1 = adx[adxperiod]
    atr = AverageTrueRange[atrperiod]
    //exitafternbars = 1
    
    //// OPTIMIZED VARIABLES/////
    k = 5
    y = 6
    adxval = 18
    atrmin = 25
    m = 3 // high vol coefficient for mean reversion
    n = 2 //high vol coefficient for brekout
    m1 = m-1 // low vol coefficient for mean reversion
    n1 = n// low vol coefficient for breakout
    pr = k*atr
    pl = y *atr
    ///////////////////////////////////////
    
    
    positionlong = saisonalpatternmultiplier*round(100/atr/2.1666)//define sixe of long trades
    positionshort = round(100/atr)// define size of short trade
    //a=5
    lowvolenvironment = atr<atrmin //define lowvol environment use m1 and n1 as coefficient of movement
    highvolenvironment = atr> atrmin //define highvol environment use m and n as coefficient of movement
    meanrevertingenv = indicator1< adxval //define meanreverting environment
    trendenv = indicator1 > adxval// define trendy environment
    
    
    //////description of the possible combinations
    sellhighvolmeanreverting = abs(open-close) > (atr*m) and close > open and meanrevertingenv and highvolenvironment
    buyhighvolmeanreverting = abs(open-close) > (atr*m) and close < open and meanrevertingenv and  highvolenvironment
    buyhighvoltrendy = abs(open-close) > (atr*n) and close > open and close> DOPEN(1) and trendenv and highvolenvironment
    sellhighvoltrendy = abs(open-close) > (atr*n) and close < open and close< DOPEN(1) and trendenv and highvolenvironment
    selllowvolmeanreverting = abs(open-close) > (atr*m1) and close > open and meanrevertingenv and lowvolenvironment
    buylowvolmeanreverting = abs(open-close) > (atr*m1) and close < open and meanrevertingenv and lowvolenvironment
    buylowvoltrendy = abs(open-close) > (atr*n1) and close > open and trendenv and lowvolenvironment
    selllowvoltrendy = abs(open-close) > (atr*n1) and close < open and trendenv and lowvolenvironment
    ////////////////////////////////////////////////////////
    
    
    
    // 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
    IF (buyhighvolmeanreverting or buyhighvoltrendy or buylowvolmeanreverting or buylowvoltrendy )  and timeenterbefore and timeenterafter  THEN
    buy positionlong CONTRACTS AT MARKET
    ENDIF
    
    if longonmarket and time = timeend then
    sell  at market
    endif
    
    // short
    IF (sellhighvolmeanreverting or sellhighvoltrendy or selllowvolmeanreverting or selllowvoltrendy) and timeenterbefore and timeenterafter THEN
    sellshort  positionshort CONTRACTS AT MARKET
    endif
    
    if shortonmarket and time = timeend then
    exitshort at market
    endif
    
    set target pprofit  pr
    set stop ploss pl
    
    #37673 quote
    kg6450
    Participant
    Average

    Ok thanks I will add that and see how it goes, is the seasonality the same for both the DOW and the DAX though?

    I tested on some currency pairs and single position for EURUSD looks promising. The equity curve could do with a bit of smoothing though

    EURUSD-MNandBK.png EURUSD-MNandBK.png
    #37675 quote
    Francesco78
    Participant
    Master

    Hi, no I dont think so, we should retrieve them from the pathfinder discussions somewhere, Ill see if I can find them tomorrow, good job for the EURUSD, I have been tried that as well before and I confirm it looked promising, but your equity looks a bit better than mine, do you mind sharing your version of the code?

    Best

    #37677 quote
    kg6450
    Participant
    Average

    Ok I’ll have a look there.

     

    Here is the code for EURUSD with a 0.6 spread

    // EUR/USD(mini) - IG MARKETS
    // TIME FRAME 1H
    // SPREAD 0.6 PIPS
    
    DEFPARAM CumulateOrders = False
    DEFPARAM FLATBEFORE =080000
    DEFPARAM FLATAFTER =210000
    adxperiod = 14
    atrperiod = 14
    indicator1 = adx[adxperiod]
    atr = AverageTrueRange[atrperiod]
    adxval = 22
    atrmin = 35
    position = 1 //round(100/atr)
    
    m = 3
    n = 1
    m1 = 2
    n1 = 2
    
    if atr>atrmin then
    c1 = indicator1 <adxval
    c2 = indicator1 >adxval
    
    if c1 then
    // short
    IF (abs(open-close) > (atr*m) and close > open)   THEN
    sellshort  position CONTRACTS AT MARKET
    
    ENDIF
    
    //long
    IF (abs(open-close) > (atr*m) and close < open)   THEN
    buy position CONTRACTS AT MARKET
    
    ENDIF
    endif
    
    if c2 then
    // long
    IF (abs(open-close) > (atr*n) and close > open and close> DOPEN(1))   THEN
    buy  position CONTRACTS AT MARKET
    ENDIF
    
    //short
    IF (abs(open-close) > (atr*n) and close < open and close< DOPEN(1))   THEN
    sellshort  position CONTRACTS AT MARKET
    ENDIF
    endif
    endif
    
    if atr<atrmin then
    c1 = indicator1 <adxval
    c2 = indicator1 >adxval
    
    if c1 then
    // short
    IF (abs(open-close) > (atr*m1) and close > open)   THEN
    sellshort  position CONTRACTS AT MARKET
    ENDIF
    
    //long
    IF (abs(open-close) > (atr*m1) and close < open)   THEN
    buy  position CONTRACTS AT MARKET
    ENDIF
    endif
    
    if c2 then
    // long
    IF (abs(open-close) > (atr*n1) and close > open )   THEN
    buy  position CONTRACTS AT MARKET
    ENDIF
    
    //short
    IF (abs(open-close) > (atr*n1) and close < open)   THEN
    sellshort  position CONTRACTS AT MARKET
    ENDIF
    endif
    endif
    

    The parameters that were optimised for were m, n, m1, n1, atrmin and adxmin

    #37729 quote
    Francesco78
    Participant
    Master

    great thanks

    here are the seasonals for the dow as per pathfinder

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

    Hello,

    Interesting code with seasonality.

    I tried another way: as I saw with my previous code that monday is the most profitable, friday the less, and about same results for other 3 days then I applied different parameters for these 3 cases.

    I have to try another idea and i’ll send the code.

    Regards.

    #37842 quote
    Francesco78
    Participant
    Master

    looking forward for it Noisette 🙂

    #37857 quote
    noisette
    Participant
    Veteran

    OK.

    I still have to do some tests because today in demo mode, position was closed after the time that it was suppose to do (23h40 so not logic with M30 strategy and “flatafter = 200000) and the code stop after.

    And for my previous code, code stopped without any position.

    Do you have this reliability problem with demo mode?

Viewing 15 posts - 61 through 75 (of 83 total)
  • You must be logged in to reply to this topic.

Dax adaptable strategy Breackout/Mean reversion


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 82 replies,
has 13 voices, and was last updated by xburrex
5 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/22/2017
Status: Active
Attachments: 26 files
Logo Logo
Loading...