DPO

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #8852 quote
    Victorio
    Participant
    Senior

    Bonsoir, quelle est la fonction “DPO” dans un code?

    ex: h1=dpo[n](high)

    Elle est refusée en automatisé.

    Peut-on contourner cela par une astuce de programmation?

    Merci.

    #8862 quote
    Nicolas
    Keymaster
    Master

    Le DPO peut se calculer de 2 façons :

    1/ avec les données du futur (ce qui n’est pas possible à récupérer pour le trading automatique)

    2/ avec les données du passé (là oui on le peut mais il faudra utiliser la formule du DPO directement dans le code et non pas l’indicateur embarqué dans la plateforme).

    Voici la formule du DPO :

    // **** DPO of past moving average and not future ones :
    
    p = 14
    
    avg = average[p](customclose)
    r = round(p/2) +1
    b = customclose - avg[r]
    myDPO = b
    
    RETURN myDPO as "Detrented Price Oscillator of past datas", 0 coloured(10,10,255) as "0"
    didi059 and Bard thanked this post
    #8884 quote
    Victorio
    Participant
    Senior

    Compris, merci bien.

    #9583 quote
    Victorio
    Participant
    Senior

    Bonjour, malgré mes nombreuses tentatives, je fais choux blanc.

    Mon but est de rendre opérant les “DARVAS BOXES” en temps réel, et non pas en “statique”, et je n’arrive à intégrer le bout de code que tu m’as transmis ci-dessus dans le code original.

    Merci  pour ton aide, si cela est possible bien entendu.

    rem from hk_lisse blog
    k=55
    once tth=undefined
    once ttl=undefined
    n=(k*2)-4
    p=(n/2)-1
    h1=dpo[n](high)
    moyh=high-h1
    hi=(moyh-moyh[1]+(high[p])/n)*n
    hi=(round(hi*100))/100
    l1=dpo[n](low)
    moyl=low-l1
    lo=(moyl-moyl[1]+(low[p])/n)*n
    lo=(round(lo*100))/100
    low1=(round(low*100))/100
    high1=(round(high*100))/100
    
    if barindex > 100 then
    if box=1 and (high1>tth or low1<ttl) then
    box=0
    flag=0
    endif
    if box=0 and flag=0 and high1>=hi[46] and high1>=hi[45] and high1>=hi[44] then
    th=high1
    flag=1
    endif
    if box=0 and flag=1 then
    for zz=0 to 44
    if  hi[47-zz-1]>th or hi[47-zz-2]>th or hi[47-zz-3]>th then
    flag=0
    break
    endif
    if lo[47-zz]<lo[47-zz-1] and lo[47-zz]<lo[47-zz-2] and lo[47-zz]<lo[47-zz-3] then
    box=1
    tth=th
    ttl=lo[47-zz]
    break
    endif
    next
    endif
    else
    tth=undefined
    ttl=undefined
    endif
    if box=1 then
    ba=ttl
    else
    ba=tth
    endif
    if box=1 then
    col=1
    else
    col=-1
    endif
    
    
    return ba coloured by col , tth coloured by col,ttl coloured by col
    #9588 quote
    Nicolas
    Keymaster
    Master

    Il suffit d’intégrer le code que j’ai donné dans ton indicateur et de faire référence à “myDPO” en lieu et place de “dpo” de ton code original.

    #9601 quote
    Victorio
    Participant
    Senior

    Aaaaaaah……OK, suis-je bête.

    Je m’y mets de suite, merci.

    #9603 quote
    Victorio
    Participant
    Senior

    J’obtiens donc un début de code comme suit, mais il y a forcément quelque chose qui cloche, au niveau de “h1″ et ” l1″, par rapport au code de base?

    Navré pour mon insistance, mais ce DARVAS me semble une excellente base de backtest, et j’aimerais vraiment arriver à quelque chose de tangible.

    p = 55
    avg = average[p](customclose)
    r = round(p/2) +1
    b = customclose - avg[r]
    myDPO = b
    k=55
    once tth=undefined
    once ttl=undefined
    n=(k*2)-4
    p=(n/2)-1
    h1=mydpo
    moyh=high-h1
    hi=(moyh-moyh[1]+(high[p])/n)*n
    hi=(round(hi*100))/100
    l1=mydpo
    moyl=low-l1
    lo=(moyl-moyl[1]+(low[p])/n)*n
    lo=(round(lo*100))/100
    low1=(round(low*100))/100
    high1=(round(high*100))/100
    #9604 quote
    Victorio
    Participant
    Senior

    Je précise que ce n’est pas destiné à du trading auto, mais à la construction et l’utilisation d’un probacktest en temps réel.

    #9608 quote
    Nicolas
    Keymaster
    Master

    Ok.

    #10874 quote
    JC_Bywan
    Moderator
    Master

    Victorio je ne pense pas qu’il soit possible d’obtenir les mêmes box comme ça. Même si je suis d’accord avec le bout de code à insérer de Nicolas pour représenter le dpo avec les moyennes mobiles passées, il suffit d’afficher le dpo existant de PRT et de cocher tour à tour “utiliser les moyennes mobiles passées”/”utiliser les moyennes mobiles futures” pour voir que ça donne des dpo vraiment très différents. Et ensuite dans le code de Darvas box les différences dues au dpo se propagent comme une boule de neige en créant des différences encore plus grandes dans le calcul de hi et lo. Il en résulte des box très différentes.

    Enfin, si je puis me permettre, dans l’insertion du bout de code de Nicolas sur le dpo, tu as un “customclose”, qui te laisse librement choisir en fenêtre de l’indicateur si tu veux l’appliquer à high , low, close, autre… Mais dans le code de Darvas box tu as 2 fois un calcul de dpo avec du high et avec du low. Or si tu laisses customclose comme tu l’as fait, et qu’après en fenêtre tu choisis high, tu vas calculer 2 fois en high (respectivement si tu choisis low tu vas calculer 2 fois en low), ça va créer des erreurs qui vont s’ajouter aux différences dues au mode de calcul des dpo. Donc tu dois adapter le code de Nicolas en traitant 2 calculs séparés de dpo, un avec high, et un autre avec low. En remplaçant le p de Nicolas par pprc pour pas confondre avec le p déjà pris dans le code de Darvas box et faciliter la lecture des 2 codes fusionnés, ça donnerait quelque chose comme ça:

     

    rem from hk_lisse blog
    k=48
    once tth=undefined
    once ttl=undefined
    n=(k*2)-4
    p=(n/2)-1
    
    pprc=n
    avg1 = average[pprc](high)
    r = round(pprc/2) +1
    myDPO1 = high - avg1[r]
    avg2 = average[pprc](low)
    myDPO2 = low - avg2[r]
    
    h1=myDPO1
    moyh=high-h1
    hi=(moyh-moyh[1]+(high[p])/n)*n
    hi=(round(hi*100))/100
    l1=myDPO2
    moyl=low-l1
    lo=(moyl-moyl[1]+(low[p])/n)*n
    lo=(round(lo*100))/100
    low1=(round(low*100))/100
    high1=(round(high*100))/100

    etc…

    en ayant mis ici pprc = n puisque le code de Darvas box utilisait les n périodes pour son calcul, mais j’ai laissé pprc en intermédiaire pour éventuellement jouer avec en mettant pprc = plus ou moins que n et voir bouger les tailles de box. Mais je pense que la conclusion sera de toute façon que quel que soit le réglage, les box sont beaucoup moins pertinentes, parce que les dpo sont trop différents au départ pour que mathématiquement on puisse retomber sur les mêmes box.

    #10877 quote
    Victorio
    Participant
    Senior

    Merci Noobywan

    Je suppose que tu m’as reconnu?  ;o)

    Je teste immédiatement ta proposition.

    A+

    #126641 quote
    rama
    Participant
    Senior

    I am t

    once rr=1
    mb=average[20](typicalprice)
    k=48
    n=(k*2)-4
    p=(n/2)-1
    
    h1=DPO[n](high)
    
    moyh=high-h1
    hi=(moyh-moyh[1]+(high[p])/n)*n
    hi=(round(hi*100))/100
    l1=dpo[n](low)
    
    moyl=low-l1
    lo=(moyl-moyl[1]+(low[p])/n)*n
    lo=(round(lo*100))/100
    clo1=dpo[n](close)
    
    moyc=close-clo1
    clot=(moyc-moyc[1]+(close[p])/n)*n
    clot=(round(clot*100))/100
    cond1=(high>high[1] and high>high[2])
    cond2=(cond1 and high>hi[46]) and (barindex>bari or rr=-1)
    if cond1 and cond2 then
    flagg=1
    targeth=high
    targetl=lo[46]
    else
    flagg=0
    signa=mb
    endif
    for zz=0 to 45
    if clot[45-zz]<targetl and hi[45-zz]<=targeth and flagg=1  then
    signa=high+(averagetruerange[20](close))*.5
    rr=1
    bari=barindex+zz+2
    break
    elsif     hi[45-zz]>targeth then
    signa=mb
    break
    endif
    next
    condi=(low<low[1] and low<low[2]) and low<lo[46] and (barindex>bar or rr=1)
    if condi then
    fflag=1
    target1=low
    target2=hi[46]
    else
    fflag=0
    siigna=mb
    endif
    for kk=0 to 45
    if clot[45-kk]>target2 and lo[45-kk]>=target1 and fflag=1 then
    siigna=low-(averagetruerange[20](close))*.5
    rr=-1
    bar=barindex+kk+2
    break
    elsif lo[45-kk]<target1 then
    siigna=mb
    break
    endif
    next
    if barindex < 100 then
    signa=undefined
    siigna=undefined
    endif
    golong = (siigna < mb)
    goshort = (signa > mb)*-1
    return golong as  "LONG",goshort as "SHORT",0

     

    I am trying to use the above indicator in my code I get the error attached. what need to be replaced for DPO

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

DPO


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Victorio @victorio Participant
Summary

This topic contains 11 replies,
has 4 voices, and was last updated by rama
5 years, 10 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 06/05/2016
Status: Active
Attachments: 1 files
Logo Logo
Loading...