Droite de régression linéaire plus 1 écart type

Viewing 11 posts - 16 through 26 (of 26 total)
  • Author
    Posts
  • #196024 quote
    smn
    Participant
    New

    Bonsoir Smn

    Sur prix : petit tableau à droite, configurer mettre les prix à l’échelle logarithmique

    Merci Supertiti, j’avais bien vu cette possibilité, mais quand je l’active la droite de régression part en sucette 🙂

    #196044 quote
    supertiti
    Participant
    Master

    De mon côté ça marche quand je passe de linéaire à logarithmique .

    #196223 quote
    smn
    Participant
    New

    Bonjour Supertiti,
    Alors, tu trouveras ci-joint la capture d’écran de la régression linéaire de Air Liquide.
    lorsque je cherche à avoir la même chose avec ton code je n’y arrive pas. Est-ce que tu peux me dire si tu as le même problème et éventuellement pourquoi ?
    Merci

    Capture-décran-2022-06-22-à-16.19.08.jpg Capture-décran-2022-06-22-à-16.19.08.jpg
    #196263 quote
    Nicolas
    Keymaster
    Master

    En effet c’est une échelle logarithmique, donc l’apparence de la régression ne sera pas la même.

    1/ j’ai modifié un peu le code pour qu’il soit plus rapide au calcul:

    //PRC_Std and Ste LinRegChannel | indicator
    //Standard Deviation and Standard Error
    //Linear Regression Channel
    //12.03.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    defparam drawonlastbaronly=true
    if islastbarupdate then
    // --- settings
    lookback= max(1,barindex) //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier
    colorRed = 255
    colorGreen = 255
    colorBlue = 0
    // --- end of settings
    
    sumx = 0
    sumy = 0
    sumxy = 0
    sumx2 = 0
    
    for cmpt = lookback downto 0 do
    tmpx = cmpt
    tmpy = close[cmpt]
    sumy = sumy+tmpy
    sumx = sumx+tmpx
    sumx2 = sumx2 + (tmpx*tmpx)
    sumxy = sumxy + (tmpy*tmpx)
    next
    
    n = lookback+1
    
    if (sumx2 = sumx * sumx) then // protection to avoid infinite values
    b = sumxy - sumx * sumy
    else
    b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
    endif
    a = (sumy - b * sumx) / n
    
    drawsegment(barindex[lookback],a+b*lookback,barindex,a+b*0) coloured("red")
    
    //channel
    if ChannelType = 1 then //Standard Deviation
    dat = std[lookback]*NbDeviation
    else
    dat = ste[lookback]*NbDeviation
    endif 
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured("gray") style(dottedline2)
    endif
    
    return

    2/ pour obtenir une régression linéaire sur votre graphique, il n’est pas obligatoire d’utiliser un code personnalisé, utilisez simplement l’outil de regression dans la plateforme (fonctionne sur échelle logarithmique) = voir image jointe.

    linear-regression-hiboo.png linear-regression-hiboo.png
    #196284 quote
    supertiti
    Participant
    Master

    Bonjour Nicolas,

    J’ai voulu doubler les lignes de déviation comme je l’avais fais mais cette fois ci le systeme me dit :

    “parametre entier avec STD” en place de loockback sur les lignes de “DAT2”

    nota : a la ligne 48 il doit y avoir une coquille ?

    Où est le bug dans mon code ?

    merci de me dire, bonne journée

     

     

    defparam drawonlastbaronly=true
    if islastbarupdate then
    // --- settings
    lookback= max(1,barindex) //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier
    colorRed = 255
    colorGreen = 255
    colorBlue = 0
    // --- end of settings
     
    sumx = 0
    sumy = 0
    sumxy = 0
    sumx2 = 0
     
    for cmpt = lookback downto 0 do
    tmpx = cmpt
    tmpy = close[cmpt]
    sumy = sumy+tmpy
    sumx = sumx+tmpx
    sumx2 = sumx2 + (tmpx*tmpx)
    sumxy = sumxy + (tmpy*tmpx)
    next
     
    n = lookback+1
     
    if (sumx2 = sumx * sumx) then // protection to avoid infinite values
    b = sumxy - sumx * sumy
    else
    b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
    endif
    a = (sumy - b * sumx) / n
     
    drawsegment(barindex[lookback],a+b*lookback,barindex,a+b*0) coloured("red")
     
    //channel
    if ChannelType = 1 then //Standard Deviation
    dat = std[lookback]*NbDeviation
    else
    dat = ste[lookback]*NbDeviation
    endif
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured("gray") style(dottedline2)
    endif
    //////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////
    
    //lookback= max(1,barindex) //channel period
    ChannelType2 = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation2 = 2 //Deviation multiplier
    //channel
    if ChannelType2 = 1 then //Standard Deviation
    dat2 = std[lookback]*NbDeviation2
    else
    dat2 = std[lookback]*NbDeviation2
    endif
    drawsegment(barindex[lookback],(a+b*lookback)+dat2,barindex,a+b*0+dat2) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat2,barindex,a+b*0-dat2) coloured("gray") style(dottedline2)
    
    return
    #196288 quote
    supertiti
    Participant
    Master

    Ok pour le STE

    #196289 quote
    Nicolas
    Keymaster
    Master

    Trop complexe de reprendre ton code, voici le mien modifié avec 2 lignes de canal haute et basse.

    //PRC_Std and Ste LinRegChannel | indicator
    //Standard Deviation and Standard Error
    //Linear Regression Channel
    //12.03.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    defparam drawonlastbaronly=true
    if islastbarupdate then
    // --- settings
    lookback= max(1,barindex) //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier
    NbDeviation2 = 0.5 //Deviation multiplier
    colorRed = 255
    colorGreen = 255
    colorBlue = 0
    // --- end of settings
    
    sumx = 0
    sumy = 0
    sumxy = 0
    sumx2 = 0
    
    for cmpt = lookback downto 0 do
    tmpx = cmpt
    tmpy = close[cmpt]
    sumy = sumy+tmpy
    sumx = sumx+tmpx
    sumx2 = sumx2 + (tmpx*tmpx)
    sumxy = sumxy + (tmpy*tmpx)
    next
    
    n = lookback+1
    
    if (sumx2 = sumx * sumx) then // protection to avoid infinite values
    b = sumxy - sumx * sumy
    else
    b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
    endif
    a = (sumy - b * sumx) / n
    
    drawsegment(barindex[lookback],a+b*lookback,barindex,a+b*0) coloured("red")
    
    //channel
    if ChannelType = 1 then //Standard Deviation
    dat = std[lookback]*NbDeviation
    dat2 = std[lookback]*NbDeviation2
    else
    dat = ste[lookback]*NbDeviation
    dat2 = ste[lookback]*NbDeviation2
    endif
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)+dat2,barindex,a+b*0+dat2) coloured("gray") style(dottedline2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat2,barindex,a+b*0-dat2) coloured("gray") style(dottedline2)
    endif
    
    return
    
    canal-regression-lineaire.png canal-regression-lineaire.png
    #196291 quote
    supertiti
    Participant
    Master

    Et voilà :

     

    // LINEAR REGRESSION CHANNEL V1 by Nicolas  28 juin 2022
    
    // LINEAR REGRESSION CHANNEL V1 by Nicolas  28 juin 2022
    // graphe style LINEAIRE
    
    defparam drawonlastbaronly=true
    if islastbarupdate then
    // --- settings
    lookback= max(1,barindex) //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier
    colorRed = 255
    colorGreen = 255
    colorBlue = 0
    // --- end of settings
     
    sumx = 0
    sumy = 0
    sumxy = 0
    sumx2 = 0
     
    for cmpt = lookback downto 0 do
    tmpx = cmpt
    tmpy = close[cmpt]
    sumy = sumy+tmpy
    sumx = sumx+tmpx
    sumx2 = sumx2 + (tmpx*tmpx)
    sumxy = sumxy + (tmpy*tmpx)
    next
     
    n = lookback+1
     
    if (sumx2 = sumx * sumx) then // protection to avoid infinite values
    b = sumxy - sumx * sumy
    else
    b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
    endif
    a = (sumy - b * sumx) / n
     
    drawsegment(barindex[lookback],a+b*lookback,barindex,a+b*0) coloured("white")style(line,5)
     
    //channel
    if ChannelType = 1 then //Standard Deviation
    dat = std[lookback]*NbDeviation
    else
    dat = ste[lookback]*NbDeviation
    endif
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured("yellow") style(line,2)
    drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured("yellow") style(line,2)
    endif
     
    ///////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured(colorRed,colorGreen,colorBlue)style(line,3)
    lookback2= max(1,barindex) //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation2 = 2  //Deviation multiplier
    //channel 2
    if ChannelType = 1 then //Standard Deviation
    dat2 = std[lookback2]*NbDeviation2
    else
    dat2 = ste[lookback2]*NbDeviation2
    endif
    drawsegment(barindex[lookback2],(a+b*lookback2)-dat2,barindex,a+b*0-dat2) coloured (0,255,8)//(colorRed,colorGreen,colorBlue)
    drawsegment(barindex[lookback2],(a+b*lookback2)+dat2,barindex,a+b*0+dat2) coloured (255,9,0)
    /////////////////////////////////////////////////////
    /////////////////////////////////////////////////////
    return customclose as " Linear regression channel V1  "
    
    
    LRC-V1.jpg LRC-V1.jpg
    #196322 quote
    smn
    Participant
    New

    Merci Nicolas, mais du coup on ne peut pas avoir un code qui fonctionne sur l’échelle logarithmique ?

    #196353 quote
    Nicolas
    Keymaster
    Master

    C’est en effet plus complexe, le code de la régression linéaire doit être réécrit. L’indicateur doit calculer lui même l’échelle, puisque la plateforme ne renvoi pas cette valeur.

    #211981 quote
    ZeroCafeine
    Participant
    Senior

    Bonjour tout le monde,


    @Ozons

    Je suis tombé sur ce sujet par hasard, je n’ai pas eu le temps de tout lire mais j’ai cliqué sur le lien de la vidéo et regarder un petit peu en accéléré,

     

    Je dirais encore un vendeur de formation, j’ai lu pas mal de bouquins de bourse et je continue toujours mon apprentissage et mon petit retour d’expérience c’est que les prix ne suivent pas une loi normale donc on ne peut pas utiliser une courbe gaussienne et donc tous les gens qui rabâche que le prix est à 95 % inclus dans deux écart-types et ben ils disent n’importe quoi c’est plutôt environ 86 % pour deux écarts (j’ai trouvé cette information dans le livre de Bollinger et de Philippe Cayenne)

    Je respecte bien toute personne qui donne du savoir, dans certaines cultures on dit : un professeur a presque la même place qu’un prophète, et bien d’autres citations de personnes célèbres comme Einstein

     

    Moi la dernière que j’ai apprise d’un très très bon ami très rigolo c’est : quand on sait pas faire et ben on l’enseigne 🤣

    Attention je ne vise personne c’est juste pour rigoler un petit peu

Viewing 11 posts - 16 through 26 (of 26 total)
  • You must be logged in to reply to this topic.

Droite de régression linéaire plus 1 écart type


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Ozons @ozons Participant
Summary

This topic contains 25 replies,
has 5 voices, and was last updated by ZeroCafeine
2 years, 11 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 06/14/2022
Status: Active
Attachments: 12 files
Logo Logo
Loading...