DAX Aroon 30 min system

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #27745 quote
    Eric
    Participant
    Master

    This system is not mine (maybe someone here recognize it) i found it years ago think it was on prorealtime site

    anyway this is the original code not optimized, the short side need improvements

    maybe with changes and money management it can be something for the library?

    DEFPARAM CumulateOrders=False
    REM Acquisto
    
    
    indicator1 = ExponentialAverage[20](close)
    indicator2 = ExponentialAverage[50](close)
    c1 = (indicator1 > indicator2[1])
    
    
    indicator3 = AroonUp[14]
    indicator4 = Aroondown[14]
    c2 = (indicator3 CROSSES OVER indicator4)
    
    
    indicator41 = Stochastic[14,3](close)
    c41 = (indicator41 <  75)
    
    
    indicator100 = close
    indicator101 = Supertrend[2,10]
    c100 = indicator100 > indicator101
    
    
    
    
    IF c1 AND c2 AND c41 AND c100 THEN
    BUY 1 contracts AT MARKET
    ENDIF
    
    
    
    
    REM Vendita
    
    
    indicator5 = close
    indicator6 = ExponentialAverage[20](close)
    c4 = (indicator5 < indicator6[1])
    
    
    indicator7 = AroonUp[14]
    indicator8 = AroonDown[14]
    c5 = (indicator7 < indicator8[1])
    
    
    IF c4 AND c5 THEN
    SELL AT MARKET
    ENDIF
    
    
    
    
    REM Vendita allo scoperto
    
    
    indicator9 = ExponentialAverage[20](close)
    indicator10 = ExponentialAverage[50](close)
    c6 = (indicator9 < indicator10[1])
    
    
    indicator11 = AroonUp[14]
    indicator12 = Aroondown[14]
    c7 = (indicator12 CROSSES OVER indicator11)
    
    
    indicator43 = Stochastic[14,3](close)
    c43 = (indicator43 > 25)
    
    
    indicator110 = close
    indicator111 = Supertrend[2,10]
    c110 = indicator111 > indicator110
    
    
    IF c6 AND c7 AND c43 AND c110 THEN
    SELLSHORT 1 contracts AT MARKET
    ENDIF
    
    
    
    
    REM Riacquisto
    
    
    indicator13 = close
    indicator14 = ExponentialAverage[20](close)
    c9 = (indicator13 > indicator14[1])
    
    
    indicator15 = AroonUp[14]
    indicator16 = AroonDown[14]
    c10 = (indicator15 > indicator16[1])
    
    
    IF c9 AND c10 THEN
    EXITSHORT AT MARKET
    ENDIF
    #27747 quote
    Eric
    Participant
    Master

    I have used a version live long only and removed stochastic and used a stoploss

    maybe with some kind of trailing stop it would perform better?

    2015 was pretty good but 2016 some draw down pre trump

    its not rocket science and get rich quick but its profitable

    DEFPARAM CumulateOrders=False
    REM Acquisto
    
    
    indicator1 = ExponentialAverage[20](close)
    indicator2 = ExponentialAverage[50](close)
    c1 = (indicator1 > indicator2[1])
    
    
    indicator3 = AroonUp[14]
    indicator4 = Aroondown[14]
    c2 = (indicator3 CROSSES OVER indicator4)
    
    
    
    
    indicator100 = close
    indicator101 = Supertrend[2,10]
    c100 = indicator100 > indicator101
    
    
    
    
    IF c1 AND c2 AND c100 THEN
    BUY 1 CONTRACTs AT MARKET
    ENDIF
    
    
    
    
    REM Vendita
    
    
    indicator5 = close
    indicator6 = ExponentialAverage[20](close)
    c4 = (indicator5 < indicator6[1])
    
    
    indicator7 = AroonUp[14]
    indicator8 = AroonDown[14]
    c5 = (indicator7 < indicator8[1])
    
    
    IF c4 AND c5 THEN
    SELL AT MARKET
    ENDIF
    
    
    SET STOP PLOSS 100
    #27755 quote
    Nicolas
    Keymaster
    Master

    Thanks Eric, but you did not mention timeframe and instrument?

    #27759 quote
    Eric
    Participant
    Master

    I have used it on DAX

    30 minute timeframe

    #27764 quote
    Eric
    Participant
    Master

    I had a version (long only) with EMA 50 and EMA 90 also

    indicator1 and indicator2

    #30807 quote
    victormork
    Participant
    Veteran

    It performs better with a trailing stop as you mentioned. Starting October 2015 it has a positiv result on FTSE100 too (30 min). The trailing stop function is from Nicolas blogpost.

    DEFPARAM CumulateOrders=False
    REM Acquisto
    
    indicator1 = ExponentialAverage[50](close)
    indicator2 = ExponentialAverage[90](close)
    c1 = (indicator1 > indicator2[1])
    
    indicator3 = AroonUp[14]
    indicator4 = Aroondown[14]
    c2 = (indicator3 CROSSES OVER indicator4)
    
    indicator100 = close
    indicator101 = Supertrend[2,10]
    c100 = indicator100 > indicator101
    
    IF c1 AND c2 AND c100 THEN
    BUY 1 CONTRACTs AT MARKET
    ENDIF
    
    SET STOP PLOSS 150
    
    //trailing stop
    trailingstop = 40
    
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    #33315 quote
    victormork
    Participant
    Veteran

    If anyone is interested, here’s the system with a Donchian stop loss.

    DEFPARAM CumulateOrders=False
    
    indicator1 = ExponentialAverage[50](close)
    indicator2 = ExponentialAverage[90](close)
    c1 = (indicator1 > indicator2[1])
    
    indicator3 = AroonUp[14]
    indicator4 = Aroondown[14]
    c2 = (indicator3 CROSSES OVER indicator4)
    
    indicator100 = close
    indicator101 = Supertrend[2,10]
    c100 = indicator100 > indicator101
    
    IF c1 AND c2 AND c100 THEN
    BUY 1 CONTRACTs AT MARKET
    ENDIF
    
    // DONCHIAN STOP
    DC=70
    e= Highest[DC](high)
    f=Lowest[DC](low)
    if longonmarket  then
    laststop = f[1]
    endif
    if shortonmarket  then
    laststop = e[1]
    endif
    if onmarket then
    sell at laststop stop
    exitshort at laststop stop
    endif
    
    //trailing stop
    trailingstop = 50
    
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    Nicolas, Eric, Maz, ALE and shephinc thanked this post
    #33568 quote
    Maz
    Participant
    Veteran
    Hi guys, @Eric, thank you for sharing this idea, which I quite like; @victormork thank you for your contribution with the stop logic. I have optimized some of the logic statements and added few more “bells and whistles” (modules) to the system which can be easily switched on and off. Most of the modules are in the interest of increasing hit rate and reducing equity curve volatility. As it stands, I have optimized a bit on DAX M30 and experimented a little on DAX H1. I think it may almost be ready to submit this to the library (Nicolas?) but hoping you guys will test it out and play around on different markets etc. Add or remove modules as you wish until it makes sense. I suggest to disengage all the modules when trying a new asset or asset class, optimize the basic variables and then add the modules one by one. Please post your results here. The modules I have added are:
    • Variable-set selection framework You can optimize differently for whatever asset and timeframe  and save the set inside a
      elsif optimization = (x) then
    • Soft time stop The soft time stop simply counts the total number of bars of in loss endured during the trade (not consecutive but total bars of loss) and once a threshold is reached, triggers a break even signal so that the trade will at least break even if/when given the chance. The variable to adjust is softTimeStopBars (0 for off else positive number for number of bars in loss to trigger)

    • Second chance Stop The second chance stop, if engaged, monitors for a trade going into profit, followed by losing x% of the maximum gain  (typically 70-90% retracement towards original entry). If this occurs a trigger is set to exit the trade when the gain reaches or exceeds the highest high of that trade’s equity curve (a second chance).  The variable scRetraceTrigger is used to set the percentage retrace before we grab a second chance exit. 0.5 = 50% retracement. 1 =  100% retracement. It can also be set to negative value for monitoring if it went into loss after first being profitable). scMinBarsInTrade suspends monitoring until the trade has been on for at least a given number of bars.

    • ATR based target (limit) Often times you want limit orders to be a proportion of the current market volatility (so that you don’t set them too far or too near). Set useATRTarget to 1 to engage the system. atrTargetMultiple determines the limit order target by multiple of atr[40]

    • ATR filter When ATR filter is engaged, no trades will be taken unless atr[40] is above the given threshold. This reduces the likelihood of weak setups.

    // -- // -- // -- // -- // -- |
    // // -- // -- // -- // -- // |
    // == Aroon System DAX M30 == |
    // -- // -- // -- // -- // -- |
    // // -- // -- // -- // -- // |
    
    // Aroon System
    // Version 1.01
    // Contributors:
    //    Eric @ prorealcode.com
    //    Victormork @ prorealcode.com
    //    Maz @ prorealcode.com
    // --------------
    // Modules:
    //    Variable set selection framework
    //    Optional donchian stop      (useDonchianStop)
    //    Optional trailing stop      (useTrailingStop)
    //    Optional soft time stop     (softTimeStopBars > 0)
    //    Optional second chance Stop (useSecondChanceStop) [version 0.11 alpha]
    //    Optional ATR based target   (useATRTarget)
    //    Optional ATR filter         (useATRFilter)
    // --------------
    // Originally developed for DAX M30
    
    DEFPARAM CumulateOrders = false
    
    // -- Variable Selection --
    once positionSize = 1
    once optimization = 1
    
    if optimization = 1 then // DAX M30 (June 2016 - Apr 2017)
    useDonchianStop     = 1                    // Engage Donchian Stop? 0:no | 1: yes
    useTrailingStop     = 1                    // Engage trailing stop? 0:no | 1: yes
    trailingStop        = 51 //50                // trailing stop distance
    once tsLongDistance = trailingStop
    once tsShortDistance= trailingStop
    
    useATRTarget        = 1                   // Engage ATR Limit 0:no | 1: yes
    atrTargetMultiple   = 21                    // Limit is x times current ATR[40]
    
    useATRFilter        = 1                   // Engage ATR filter 0: no | 1: yes
    atrThreshold        = 15 // 11              // only trade if ATR is above x
    
    useSecondChanceStop = 0                   // Engage 2nd chance stop. 0: off | 1: on
    scRetraceTrigger    = 0.5 // 0.4            // % of max profit reduction to trigger 
    scMinBarsInTrade    = 14  // 2              // min # bars before trigger     
    
    softTimeStopBars    = 37 // 35 // 0: off | lower = higher hit rate
    
    maShortPeriod       = 50                  // short term MA period
    maLongPeriod        = 90                  // long term MA period
    arroonPeriod        = 14
    once arroonUpPeriod = arroonPeriod
    once arroonDnPeriod = arroonPeriod
    
    stMultiplier        = 2                   // Super trend multiplier
    stPeriods           = 7 // 10             // Super trend period
    donchianChPeriod    = 61 //70
    
    tradingTime         = 1//(time >= 080000 and time < 163000)
    
    elsif optimization = 2 then // DAX H1 (experimental)
    useATRTarget         = 0
    atrTargetMultiple   = 21
    softTimeStopBars    = 0
    useATRFilter         = 0
    atrThreshold         = 15
    useSecondChanceStop = 0
    //scRetraceTrigger    = 0.5 // 0.4
    //scMinBarsInTrade    = 14  // 2
    
    useDonchianStop      = 1
    useTrailingStop      = 1
    trailingStop         = 45 // 48 //43
    once tsLongDistance  = trailingStop
    once tsShortDistance = trailingStop
    
    arroonPeriod         =  14 // 15
    once arroonUpPeriod = arroonPeriod
    once arroonDnPeriod = arroonPeriod
    
    stMultiplier        = 3.5 // 3.75
    stPeriods           = 14 // 13
    donchianChPeriod    = 50 // 55 //70
    
    maShortPeriod       = 53
    maLongPeriod        = 90
    
    tradingTime = 1 //(time >= 080000 and time < 163000)
    
    endif
    
    
    // -- Indicators -----
    maShrt = exponentialAverage[maShortPeriod](close)
    maLong = exponentialAverage[maLongPeriod](close)
    arUp   = aroonUp[arroonUpPeriod]
    arDn   = aroonDown[arroonDnPeriod]
    sTrend = supertrend[stMultiplier, stPeriods]
    atr    = averageTrueRange[40]
    inProfit = onMarket and positionPerf > 0 // ignore for now
    
    // -- Entry conditions -----
    // - Long entry -
    bc1 = not longOnMarket and tradingTime
    bc1 = bc1 and (arUp CROSSES OVER arDn)
    bc1 = bc1 and (maShrt > maLong[1]) and (close > sTrend)
    bc1 = (bc1 and useATRFilter and atr > atrThreshold) or (bc1 and (not useATRFilter))
    
    // -- Short entry conditions (AKA long exit) ----
    sc1 = not ShortOnMarket
    sc1 = sc1 and (arUp crosses under arDn)
    sc1 = sc1 and (maShrt < maLong[1]) and (close < sTrend)
    //sc1 = sc1 and (maLong < maLong[2])
    
    
    // -- Donchian Stop Logic -----
    if useDonchianStop and onMarket then
    if longOnMarket  then
    dcLo = lowest[donchianChPeriod](low)
    dcLastStop = dcLo[1]
    sell at dcLastStop stop
    elsif shortOnMarket  then
    dcHi = highest[donchianChPeriod](high)
    dcLastStop = dcHi[1]
    exitshort at dcLastStop stop
    endif
    endif
    
    
    // -- Trailing Stop Logic -----
    if useTrailingStop then
    once tsLong  = tsLongDistance  * pointsize
    once tsShort = tsShortDistance * pointsize
    if (not onMarket) then
    tsMaxPrice = 0
    tsMinPrice = close
    tsExitLevel = 0
    elsif (onMarket and tsExitLevel > 0) then
    exitShort at tsExitLevel stop
    sell      at tsExitLevel stop
    elsif longOnMarket then
    tsMaxPrice = max(tsMaxPrice,close)
    if tsMaxPrice-tradeprice(1) >= tsLong then
    tsExitLevel = tsMaxPrice - tsLong
    endif
    elsif shortOnMarket then
    tsMinPrice = MIN(tsMinPrice,close)
    if tradePrice(1)-tsMinPrice >= tsShort then
    tsExitLevel = tsMinPrice + tsShort
    endif
    endif
    endif
    
    
    // -- ATR based target --
    if onMarket and useATRTarget then
    set target pProfit (atr * atrTargetMultiple) * pointSize
    endif
    
    
    // -- Soft Time Stop --
    if onMarket and softTimeStopBars > 0 then
    if not inProfit then
    countLosingBars = countLosingBars + 1
    endif
    if countLosingBars >= softTimeStopBars and inProfit then
    sc1 = 1 /// can exit
    endif
    elsif not onMarket and countLosingBars > 0 then
    countLosingBars = 0
    endif
    
    
    // -- Second chance profit lock -----
    if onMarket and useSecondChanceStop then
    once scTriggered = 0
    once maxPerf     = 0
    if scTriggered and positionPerf >= maxPerf then
    sc1 = 1
    else
    maxPerf     = max(maxPerf, positionPerf)
    scTriggered = (barIndex - tradeIndex >= scMinBarsInTrade) 
    scTriggered = scTriggered and positionPerf <= (maxPerf * scRetraceTrigger)
    endif
    elsif useSecondChanceStop and (not onMarket) and maxPerf > 0 then
    // Reset when off market
    maxPerf = 0
    scTriggered = 0
    endif
    
    
    // -- execution logic -----
    if bc1 then
    buy positionSize contracts at market
    elsif sc1 then // and (not inProfit) then
    if onmarket then
    sell at market // exit long position if short setup triggerd
    endif
    //sellshort positionSize contracts at market
    endif
    
    Henrik, ALE, Eric and 4 others thanked this post
    Aroon-system-concept.png Aroon-system-concept.png
    #33801 quote
    victormork
    Participant
    Veteran
    As always, beautiful work Maz! Is there anyone who can test this on 200 000 bars?
    #33804 quote
    ALE
    Moderator
    Master
    Hi Guys, here below test results 200.000 as soon a possible I’ll test variables optim. by Walk farward Regards Ale
    Maz, Henrik and victormork thanked this post
    DAX-AROON-SYSTEM_MAZ_V1.jpg DAX-AROON-SYSTEM_MAZ_V1.jpg
    #33821 quote
    Maz
    Participant
    Veteran
    @ALE I see your backtest begins in 2008. I have a couple of points about these kind of backtests:
    1. It’s nice to see that even with the current variable set, the system stays roughly stable on historic OOS data. That’s a good sign
    2. In 2008 we had completely different market dynamics – it was another decade which is ancient in terms of optimizing modern algos. Price action dynamics didn’t shift as fast then as they do now. So whether it makes sense to go that far back on a 30 minute system?
    3. It will be very interesting to see walk forward results for that whole period. I’d imagine you’d need to keep the ranges quite wide to accommodate the difference in volume and volatility. In 2008 we are going through a crash / bear market; then low volatility period (towards 2013) and then high volatility period (now).
    4. Spreads were VERY VERY different in 2008!
    5. I don’t expect most of my production algos that we run today to work in 2 years from now, let alone in 10 years – but if they do, that’s a great sign!
    Thanks for the contribution. Looking forward to the results.
    #33822 quote
    ALE
    Moderator
    Master
    @Maz, Very interesting your opininion, I’m agree with you. your post opens a very interesting discussion. We want to talk about it in a specific topic. I would like to ask some questions, I have always been in the midst of two schools of thought. Thanks PS: I’l came back soon with the results!
    Maz thanked this post
    #37067 quote
    Henrik
    Participant
    Veteran
    Hi! Have anyone tried this one on the short side? Regards Henrik
    #37068 quote
    Nicolas
    Keymaster
    Master
    I can not believe I missed this topic previously .. Thank you Maz for the enhanced version with add-ons! Has anyone managed to do a walk-forward analysis?
    #47305 quote
    Eric
    Participant
    Master
    i try this one on bitcoin (demo) just for fun, the spread will make it hard to make some profit   p.s i have sometimes problem with the “usedonchianstop” so i dont use it (changed it to zero) i think its something with price distance to the stoporder?
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.

DAX Aroon 30 min system


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Eric @eric Participant
Summary

This topic contains 19 replies,
has 6 voices, and was last updated by Eric
8 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/08/2017
Status: Active
Attachments: 4 files
Logo Logo
Loading...