D.I.+RSIOMA Trend Following on Dax

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #75002 quote
    AlgoAlex
    Participant
    Master

    Hi guys,

    I was trying to figure out some strategies with a mtf trend background and entry in direction of it, and I found this out:

    a double-Directional Movement to set the direction of the trend, and RSIOMA crossing overbought or oversold for entry signal.

    A little bit of money management (to improve possibly with your help) optimization and here an interesting result on 100k backtest.

    //ADX+RSIOMA Trend Follower by AlexF81
    //DAX 1H optimized on 100k bars
    
    DEFPARAM CUMULATEORDERS=true
    
    //time and days
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    TODFromHour = 090000 //time of the day
    TODToHour = 170000 //time of the day
    inTimeInterval = time>=TODFromHour and time<TODToHour
    
    //indicators
    ADX89=DI[89](close)
    ADX144=DI[144](close)
    
    trendlong=ADX89>0 and ADX144>0
    trendshort=ADX89<0 and ADX144<0
    
    ma=ExponentialAverage[14](WeightedClose)
    rsioma=rsi[14](ma)
    entrylong=rsioma crosses over 80
    entryshort=rsioma crosses under 20
    
    ///////////////////////////////////////////
    if inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
    buy 1 contracts at market
    endif
    
    if inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
    sellshort 1 contracts at market
    endif
    
    ////money management - breakeven
    startBreakeven = 10 //how much pips/points in gain to activate the breakeven function?
    PointsToKeep = 2 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated
    
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
     
    // --- BUY SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    // --- end of BUY SIDE ---
    
    //sell side
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    EXITSHORT AT breakevenLevel STOP
    ENDIF
    
    
    
    //SuperTrend as Trailing and Stop
    mySuper=1.5*Supertrend[3,10]
    
    if longonmarket and close crosses under mySuper then
    sell at market
    endif
    
    if shortonmarket and close crosses over mySuper then
    exitshort at market
    endif
    
    
    set target pprofit 200
    DAX1.jpg DAX1.jpg DAX2.jpg DAX2.jpg DAX-1H-ADXRSIOMA.itf
    #75008 quote
    Vonasi
    Moderator
    Master

    By just making sure that any additional positions are only bought at a more favourable price you can improve the gain/loss ratio, gain per trade and win rate considerably and make a nicer equity curve. This is obviously at the cost of less trades which in real life is a good thing but for a back test result is a bad thing as you have a smaller data sample to build confidence in the results.

    I used a spread of 2 and my equity curve with your code was much uglier than yours – what spread did you use? My trading time may be different too – what time are you trading on?

    I got these results with that simple addition:

    [attachment file=75009]

    [attachment file=75010]

    Screenshot_1.png Screenshot_1.png Screenshot_2.png Screenshot_2.png
    #75012 quote
    AlgoAlex
    Participant
    Master

    Thanks Vonasi,

    would you share the code you added?

    Thanks

    #75014 quote
    Vonasi
    Moderator
    Master

    Ooops – just realised that I posted only images for 10K bars!

    Here are the right ones:

    [attachment file=75015]

    [attachment file=75016]

    Screenshot_3.png Screenshot_3.png Screenshot_4.png Screenshot_4.png
    #75018 quote
    Vonasi
    Moderator
    Master

    Not sure that code adds much then although I don’t know what your draw down was as it is not in your image.

    #75019 quote
    AlgoAlex
    Participant
    Master

    Here my drowdown.

    Please would you share the code added?

    DAX1-1.jpg DAX1-1.jpg
    #75022 quote
    Vonasi
    Moderator
    Master

    I changed lines 25 to 31 with this:

    if not longonmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
    buy 1 contracts at market
    endif
    
    if longonmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong and close < positionprice then
    buy 1 contracts at market
    endif
     
    if not shortonmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
    sellshort 1 contracts at market
    endif
    
    if shortonmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort and close > positionprice then
    sellshort 1 contracts at market
    endif
    AlgoAlex thanked this post
    #75023 quote
    AlgoAlex
    Participant
    Master

    Ok, now I understood your idea.

    Not sure how much is an improvement though, since this strategy enter when a strong trend occurs, so a retracement of price is not common (unless a reversal take place).

    #75024 quote
    Vonasi
    Moderator
    Master

    Removing the trendlong and trendshort conditions from the second buy conditions helps a lot:

    [attachment file=75025]
    [attachment file=75026]

    You need to be aware that this is a version of averaging down and comes with some dangers. I have not really checked out your stop criteria yet to know how dangerous this idea is!

    Screenshot_5.png Screenshot_5.png Screenshot_6.png Screenshot_6.png
    #75028 quote
    Vonasi
    Moderator
    Master

    This is the code used in that last idea. It also changed not longonmarket and not shortonmarket to not onmarket.

    if not onmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
    buy 1 contracts at market
    endif
    
    if longonmarket and inTimeInterval and not daysForbiddenEntry and entrylong and close < positionprice then
    buy 1 contracts at market
    endif
     
    if not onmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
    sellshort 1 contracts at market
    endif
    
    if shortonmarket and inTimeInterval and not daysForbiddenEntry and entryshort and close > positionprice then
    sellshort 1 contracts at market
    endif
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

D.I.+RSIOMA Trend Following on Dax


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
AlgoAlex @alexf Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by Vonasi
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/01/2018
Status: Active
Attachments: 10 files
Logo Logo
Loading...