Trading Strategy ADX/ADM

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #25732 quote
    AleX
    Participant
    Senior

    Hello everybody,

    i think can be beautiful to create an automatization of ADX/ADM trading from the system by xinian. His system is very polular on italian finance forum. And he have a blog xinian.altervista.org.

    His system can be applied on a lot of index and commodities and have a very good return for example DAX 26% annually and a max DD of 6%. Look the attachment.

    I post his indication for his strategy:

     

    The TS ADX / ADM

    The ADX or Average Directional Index is an excellent medium-term indicator, however, It indicates only the strength of the trend and not its direction.
    The ADX value can be between 0 and 100. Typically, a trend characterized by a ADX below 20 is considered weak, while above 25 is considered strong.
    Much more useful indicators + DI (Positive Directional Indicator) and -DI (Negative Directional Indicator), considering their average to 14 days: + DI14 -DI14 in green and red.
    Their intersections determinate the direction of the trend.
    + DI14> -DI14 FlatZone + = LONG
    + DI14 <-DI14-Flatzone = SHORT
    FLAT in -Flatzone + Flatzone crossover band
    the Flatzone was -10% + 10% in older versions, now it is also calculated on the basis of periodic backtest
    ADM or Average Daily Movement is an indicator based on the Intraday volatility
    They are given daily 2 entry (Long or Short) and 3 Take Profit (Long and Short)

    Operationally:
    you enter long / short if the hourly closing (at 10, at 11, etc.) the index value is above / below the Entry long / short daily then
    if it does not arrive within the TP xx closure:
    -if we are in trend (see ADX) you go over and the next day closes if it enters the reverse signal
    -if we controtrend (ADX contrary) closes in foreclosure

    for example…
    the signal I enter long with 3 positions (3 contracts, etc …)
    the 1st pos goes to take profit on the TP1 (at bat)
    the 2nd on TP2 (at bat) once made the TP1 (hourly candle) gets up the stop loss sull’entry
    the 3rd on TP3 (at bat) once made the TP2 (hourly candle) gets up the stop loss on TP1
    – If ADX is FLAT or LONG, if he has not reached a target moves into the position over … ..
    the day after reaching the TP1 will sell all positions and expect the new signals, but if it does not reach the former tp1 but enters the entry contrary closes everything and it’s reversal.
    – If ADX is better to close it SHORT day

    Calculation of intraday levels
    ADM is the average of N-days of daily volatility (Max-Min), average days in N …
    I now calculating periodically according to the backtest and you find it in the upper left in the graph, in early versions of the TS I used the value of 30 days, which is good enough
    , Others use other values ​​..
    the input levels are calculated in this way
    The entry levels are calculated this way:
    the standard theory says to use a break-out level = 0.382 (Price Break), lately I’m calculating each day based on volatility
    (Closed on previous + Price Break * ADM Ndays) gives us the Entry Long
    (Closing the previous day – Price Break * ADM Ndays) gives us the Entry Short
    DayC = previous closing day
    C = current price
    Long Entry C => ((DayC) + ((Price Break) * (ADM Ndays)));
    Entry Short = C <((DayC) – ((* Price Break (ADM Ndays)));
    I noticed, however, when volatility increases the price break place to 0.382 generate several false signals
    Therefore, since version 3.0 I’m experiencing this formula …
    Price Break = (0.382 + 0.382 * ((10 days ADM-ADM Ndays) / ADM Ndays))
    The targets are determined as … instead.
    Target 1 = Long (12:45 * ADM) + Entry Long;
    Target 2 Long = (0.95 * ADM) + Entry Long;
    Target 3 Long = (1.95 * ADM) + Entry Long;
    Target 1 = Entry Short Short- (12:45 * ADM);
    Target = Entry 2 Short Short- (0.95 * ADM);
    Target = 3 Short Entry Short- (1.95 * ADM);

     

    This is the ADM code for the indicator 1h timeframe:

    AAA=(DHigh(1)-DLow(1))
    admn=(AAA[26]+(AAA)[25]+(AAA)[24]+(AAA)[23]+(AAA)[22]+(AAA)[21]+(AAA)[20]+(AAA)[19]+(AAA)[18]+(AAA)[17]+(AAA)[16]+(AAA)[15]+(AAA)[14]+(AAA)[13]+(AAA)[12]+(AAA)[11]+(AAA)[10]+(AAA)[9]+(AAA)[8]+(AAA)[7]+(AAA)[6]+(AAA)[5]+(AAA)[4]+(AAA)[3]+(AAA)[2]+(AAA)[1])/26
    AAB=(DCLOSE(1))
    El=(AAB+(0.266*admn))
    es=(AAB-(0.266*admn))
    el1=((0.45*admn)+el)
    el2=((0.95*admn)+el)
    el3=((1.95*admn)+el)
    es1=(es-(0.45*admn))
    es2=(es-(0.95*admn))
    es3=(es-(1.95*admn))
    
    
    RETURN el,es,el1,el2,el3,es1,es2,es3

    There is also someone that tried without success to code the strategy here:

    Qui sotto il codice PRT per l’ADM daily:

    ***********************************

    //Settaggio ADM
    X = 30
    admX=0
    FOR i=1 TO X DO
    admX=admX+(Dhigh(i)- Dlow(i))
    NEXT
    admX = admX / X
    
    //Settaggio ADM per calcolo PriceBreak
    Y = 10
    admY=0
    FOR i=1 TO Y DO
    admY=admY+(Dhigh(i)- Dlow(i))
    NEXT
    admY = admY / Y
    
    //PriceBreak = 0.324
    PriceBreak = (0.382+0.382*((admY-admX)/admX))
    
    EntryLong=(Dclose(1)+(PriceBreak*admX))
    EntryShort=(Dclose(1)-(PriceBreak*admX))
    tp1L=((0.45*admX)+EntryLong)
    tp2L=((0.95*admX)+EntryLong)
    tp3L=((1.95*admX)+entryLong)
    tp1S=(EntryShort-(0.45*admX))
    tp2S=(EntryShort-(0.95*admX))
    tp3S=(EntryShort-(1.95*admX))
    
    RETURN EntryLong COLOURED(0, 255, 0),EntryShort COLOURED(255, 0, 0), tp1L COLOURED(0, 0, 255),tp2L,tp3L,tp1S COLOURED(0, 0, 255),tp2S,tp3S
    
    

    **********************

    QUI SOTTO INVECE IL CODICE DEL SISTEMA DI TRADING:

    *********************

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate
    //DEFPARAM FlatAfter = 170000
    //DEFPARAM FlatBefore = 090000
    
    //PARAMETRI
    
    EntryLong, EntryShort, tp1L, tp2L, tp3L, tp1s, tp2s, tp3s= CALL "Xinian ADM Daily X"
    
    numerocontratti = 1
    OraInizio = 2.1
    OraFine = 23.00
    ora=currenthour
    condizioneday= ora > OraInizio and ora < OraFine
    // Condizioni per entrare su posizioni long
    
    IF NOT LongOnMarket AND Close >= EntryLong AND high[0] < tp1l and condizioneday THEN
    BUY 3*numerocontratti CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni long
    
    If LongOnMarket AND COUNTOFPOSITION = 3*numerocontratti then
    sell 1*numerocontratti contracts at tp1L[ barindex - tradeindex(1) +1 ] limit
    sell 3*numerocontratti contracts at EntryShort stop
    ENDIF
    
    If longonmarket and countofposition = 2*numerocontratti then
    sell 1*numerocontratti contracts at tp2L[ barindex - tradeindex(2) +1 ] limit
    sell 2*numerocontratti contracts at tradeprice(2) stop
    endif
    
    If longonmarket and countofposition = 1*numerocontratti then
    sell 1*numerocontratti contracts at tp3L[ barindex - tradeindex(3) +1 ] limit
    sell 1*numerocontratti contracts at tp1L[ barindex - tradeindex(3) +1 ]stop
    endif
    
    // Condizioni per entrare su posizioni short
    
    IF NOT ShortOnMarket AND Close <= EntryShort and low[0]>tp1s and condizioneday THEN
    SELLSHORT 3*numerocontratti CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni short
    If ShortOnMarket AND COUNTOFPOSITION = -3*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp1S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 3*numerocontratti contracts at EntryLong stop
    ENDIF
    
    If ShortOnMarket and countofposition = -2*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp2S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 2*numerocontratti contracts at tradeprice(2) stop
    endif
    
    If ShortOnMarket and countofposition = -1*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp3S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 1*numerocontratti contracts at tp1S[ barindex - tradeindex(3) +1 ]stop
    endif
    
    // Stop e target
    //SET STOP %LOSS 2
    //SET TARGET %PROFIT 1

     

    *********************

    I’m not a good programmer but maybe someone can find this information interesting and can process a better system. And with the automatic trading system active it will be great to optimize it with a good money management or a seasonal optimization.

    adx-dax11.jpg adx-dax11.jpg
    #25741 quote
    GraHal
    Participant
    Master

    Hi Alex, just out of interest (for me) and to try and keep Nicolas in good health … could you not see the ‘Insert PRT Code’ button by any chance at all?  Often I can’t see it either.

    I use Firefox and I have found by going Tools, Options, Privacy, Clear Recent History then I need only to tick ‘Site Preferences’ then Clear Now and refresh the PRC Site screen and I see the Insert PRC Code again. Takes me a few seconds but saves Nicolas and the Moderators several minutes and lots of frustration.

    Just a few thoughts anyway, but I often wonder if fellow members can’t see the Insert PRt Code button also??

    Cheers
    GraHal

    AleX thanked this post
    #25745 quote
    Nicolas
    Keymaster
    Master

    AleX post modified, thanks GraHal, I need you as a moderator! to “keep me in good health”! 🙂 (seriously)..

    #25798 quote
    AleX
    Participant
    Senior

    Thanks Nicolas (and sorry for the extra-work),

    I found the problem to replicate the original system with this code, the person who made the system code didn’t put the Flatzone condition into the system and didn’t use ADX for stay or exit position as Xinian recommended. And no optimization of various part of the code.

    I will try to create the basics code for this system in the next days as the initial indications.

    #25807 quote
    Nicolas
    Keymaster
    Master

    AleX, please keep this topic alive with beta versioning and/or questions if needed. We’ll try to help you the most! 🙂 Thanks.

    #25859 quote
    AleX
    Participant
    Senior

    Here, the code of the original xin idea. With the incorporated ADM indicator.

    • Condition entry with 3 position= cross over entry ADMLong
    • Exit 1 position at TargetPprofitLong1, 1 Position TPL2, 1 position TPL3
    • Stop loss at start ShortProfit1, after TP1 moved to EntryLong, after TP2 moved to TP1
    • Filter: DI+ DI- distance min 66%,
    • Entry level calc: Pricebreak formula
    • Multiday filter if at the end of the day we are on market, with ADX condition: if ADX>25 stay on market else exit

    The original Xin strategy have on dax the double profit and the half DD but is optimized time by time, i don’t know with which frequency.

    Maybe can be useful for someone have this code.

    Comment or suggestion?

    
    //Version beta 0.1
    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate
    //DEFPARAM FlatAfter = 170000
    //DEFPARAM FlatBefore = 080000
    
    //INDICATORE ADM
    n=85
    admX=0
    FOR i=1 TO n DO
    admX=admX+(Dhigh(i)- Dlow(i))
    NEXT
    admX = admX / n
    
    
    //setting ADM for PriceBreak
    y=10
    admY=0
    FOR i=1 TO Y DO
    admY=admY+(Dhigh(i)- Dlow(i))
    NEXT
    admY = admY / Y
    
    //PRICEBREAK
    PB=0.326
    PriceBreak = (PB+PB*((admY-admX)/admX))
    
    EntryLong=(Dclose(1)+(PriceBreak*admX))
    EntryShort=(Dclose(1)-(PriceBreak*admX))
    tp1L=((0.45*admX)+EntryLong)
    tp2L=((0.95*admX)+EntryLong)
    tp3L=((1.95*admX)+entryLong)
    tp1S=(EntryShort-(0.45*admX))
    tp2S=(EntryShort-(0.95*admX))
    tp3S=(EntryShort-(1.95*admX))
    
    //FLATZONE
    flatzone=0.66
    
    //CALC FLATZONE LONG
    flatlong=0
    if DIplus[14](close) > DIminus[14](close)+(DIminus[14](close)*flatzone) then
    flatlong=1
    else
    flatlong=0
    endif
    
    
    
    //CALCOLO FLATZONE SHORT
    flatSHORT=0
    if DIplus[14](close) < Diminus[14](close)-(DIminus[14](close)*flatzone) then
    flatshort=1
    else
    flatshort=0
    endif
    
    
    
    //CONDIZIONE ADX for multiday open position
    if ADX[14]>ADXR[14] and ADX[14]>25 then
    ADXcond=1
    else
    ADXcond=0
    endif
    
    
    numerocontratti = 1
    OraInizio = 09.00
    OraFine = 21.00
    ora=currenthour
    condizioneday= ora > OraInizio and ora < OraFine
    
    // Long
    IF NOT LongOnMarket AND Open <= EntryLong and Close >= EntryLong AND high[0] < tp1l and condizioneday and flatlong=1 THEN
    BUY 3*numerocontratti CONTRACTS AT MARKET
    ENDIF
    
    // EXIT long
    If LongOnMarket AND COUNTOFPOSITION = 3*numerocontratti then
    sell 1*numerocontratti contracts at tp1L[ barindex - tradeindex(1) +1 ] limit
    sell 3*numerocontratti contracts at EntryShort stop
    ENDIF
    
    If longonmarket and countofposition = 2*numerocontratti then
    sell 1*numerocontratti contracts at tp2L[ barindex - tradeindex(2) +1 ] limit
    sell 2*numerocontratti contracts at tradeprice(2) stop
    endif
    
    If longonmarket and countofposition = 1*numerocontratti then
    sell 1*numerocontratti contracts at tp3L[ barindex - tradeindex(3) +1 ] limit
    sell 1*numerocontratti contracts at tp1L[ barindex - tradeindex(3) +1 ]stop
    endif
    
    //Multiday decision
    if currenthour=OraFine and longonmarket then
    if ADXcond=0 then
    SELL AT MARKET
    endif
    endif
    
    // Condizioni per entrare su posizioni short
    
    IF NOT ShortOnMarket AND Open >= EntryShort and Close <= EntryShort and low[0]>tp1s and condizioneday and flatshort=1 THEN
    SELLSHORT 3*numerocontratti CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni short
    If ShortOnMarket AND COUNTOFPOSITION = -3*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp1S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 3*numerocontratti contracts at EntryLong stop
    ENDIF
    
    If ShortOnMarket and countofposition = -2*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp2S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 2*numerocontratti contracts at tradeprice(2) stop
    endif
    
    If ShortOnMarket and countofposition = -1*numerocontratti then
    EXITSHORT 1*numerocontratti contracts at tp3S[ barindex - tradeindex(1) +1 ] limit
    EXITSHORT 1*numerocontratti contracts at tp1S[ barindex - tradeindex(3) +1 ]stop
    endif
    
    if currenthour=OraFine and ShortOnMarket then
    if ADXcond=0 then
    EXITSHORT AT MARKET
    endif
    endif
    
    
    Schermata-2017-02-21-alle-10.48.55.png Schermata-2017-02-21-alle-10.48.55.png
    #26493 quote
    Nicolas
    Keymaster
    Master

    Thanks Alex, even if the strategy seems to perform well in backtests, it is still not possible to perform partial close with ProOrder 🙁 So it can’t be traded live I’m sorry ..

    AleX thanked this post
    #31983 quote
    gabri
    Participant
    Master

    From what I understood the flatzone is not a costant value but changes with backtests. It would be interesting knowing how is it calculated.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Trading Strategy ADX/ADM


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
AleX @bidolia Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by gabri
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/20/2017
Status: Active
Attachments: 2 files
Logo Logo
Loading...