breakout ligne de tendance

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #241359 quote
    christophe11560
    Participant
    Senior

    Bonjour,
    J’ai besoin de calculer une ligne de tendance entre les 2 sommets consécutifs baissiers les plus récents ou entre les 2 creux haussiers les plus récents.
    Creux et sommet défini comme suit:
    *creux= low[2]>low[1] and low[1]high
    En effet, je dois connaître le niveau de prix de la ligne de tendance les jours suivant le dernier sommet ou le dernier creux définis suivant les conditions ci-dessus.

    Pour ajouter des conditions complémentaires à ma stratégie, je dois également connaître les valeurs suivantes:
    – Pour les 2 sommets consécutifs à la baisse notés S1 et S2:
    * Le niveau de prix (clôture) et la position de S1
    * Le niveau de prix (clôture) et la position de S2
    – Pour les 2 creux consécutifs à la hausse notés C1 et C2:
    * Le niveau de prix (clôture) et la position de C1
    * Le niveau de prix (clôture) et la position de C2

    En vous remerciant par avance!

    #241367 quote
    christophe11560
    Participant
    Senior

    Nota: Petites erreurs de frappe, lire:
    Creux et sommet définis comme suit:
    *creux= low[2]>low[1] and low[1]high

    #241368 quote
    christophe11560
    Participant
    Senior
    //excuser moi, il y a un soucis lors de l'envoi, le message est tronqué.
    creux= low[2]>low[1] and low[1]<low
    sommet= high[2]<high[1] and high[1]>high
    #241453 quote
    Iván González
    Moderator
    Master

    Bonjour. Ce code vous servira de base pour faire ce que vous voulez. Au final ce que vous recherchez c'est un point x,y qui se trouve à l'intérieur d'une droite qui passe par 2 points x1,y1 (creux) et x2,y2 (sommet). Cela doit être vrai (x-x1)/(x2-x1) = (y-y1)/(y2-y1) . y = y1+(x-x1)*(y2-y1)/(x2-x1) nous effaçons le Y que vous avez pour n'importe quelle valeur par rapport à celle que vous proposez. Il vous suffit d'ajuster cette partie à vos intérêts et elle sera prête.

    //Punto Rotura de linea de maximos
    ////inputs/////////////////
    prd = 10
    /////pivots low
    if low > low[prd] and lowest[prd](low) > low[prd] and low[prd] < lowest[prd](low)[prd+1] then
    $pl[z+1] = low[prd]
    $plx[z+1] = barindex[prd]
    z = z + 1
    endif
    /////pivots high
    if high < high[prd] and highest[prd](high)<high[prd] and high[prd]>highest[prd](high)[prd+1] then
    $ph[t+1]=high[prd]
    $phx[t+1]=barindex[prd]
    t=t+1
    endif
    ////////////////////////////////////////////////////////////
    if islastbarupdate then
    for j=t downto 0 do
    if $ph[j] < $ph[max(0,j-1)] then
    $Highlow[j] = $ph[j]
    $Highlowx[j] = $phx[j]
    else
    $HighMax[j] = $ph[j]
    $HighMaxx[j] = $phx[j]
    break
    endif
    next
    //(x-x1)/(x2-x1) = (y-y1)/(y2-y1)
    y1 = $Highmax[max(0,lastset($Highmax))]
    x1 = $Highmaxx[max(0,lastset($Highmaxx))]
    y2 = $Highlow[max(0,lastset($Highlow))]
    x2 = $Highlowx[max(0,lastset($Highlowx))]
    for i=barindex downto x2 do
    yy = y1+(i-x1)*(y2-y1)/(x2-x1)
    if close[barindex-i] > yy and close[barindex-i+1] < yy then
    drawarrowup(i,low[barindex-i+1])
    xx=i
    BREAK
    endif
    next
    lowestlow=y1
    for i=x1 to xx do
    if low[barindex-i] < lowestlow then
    lowestlow=low[barindex-i]
    lowestlowx=i
    else
    lowestlow=lowestlow
    endif
    next
    x = barindex+1
    y = y1+(x-x1)*(y2-y1)/(x2-x1)
    Drawsegment(x1,y1,x,y)
    drawpoint(x1,y1,2)coloured("blue")
    drawpoint(xx,yy,2)coloured("blue")
    drawpoint(lowestlowx,lowestlow,2)coloured("red")
    endif
    
    ////////draw pivot points
    if z <> z[1] then
    drawtext("L",barindex[prd],low[prd]-0.35*tr)
    elsif t <> t[1] then
    drawtext("H",barindex[prd],high[prd]+0.35*tr)
    endif
    
    
    return 
    
    plbourse and christophe11560 thanked this post
    #241460 quote
    LucasBest
    Participant
    Junior

    Bonjour Iván,
    tu peux accélérer sensiblement ton code, notamment en simplifiant les lignes qui détectent les points pivots, ligne 5 et 11 :

    If low[prd] = lowest[prd*2+1](low) then
    #241474 quote
    Iván González
    Moderator
    Master

    Bien sûr ! Merci pour votre contribution

    #243113 quote
    christophe11560
    Participant
    Senior

    Bonjour Ivan,
    Comment je peux déterminer la valeur de cassure de la ligne de tendance à la hausse ? (ligne passant par 2 sommets plus bas ou 2 creux plus haut)

    Bien à toi

    #243147 quote
    christophe11560
    Participant
    Senior

    Bonjour,
    Lire valeur de cassure à déterminer pour une ligne à la hausse ou à la baisse, respectivement ligne passant par 2 sommets plus bas ou 2 creux plus haut l’un de l’autre.

    😉

    #243150 quote
    Iván González
    Moderator
    Master

    Bonjour. il faudrait créer une boucle. Avec l'équation de la droite y = y1+(x-x1)*(y2-y1)/(x2-x1) il faudrait analyser barre par barre quand le croisement se produit.

    christophe11560 thanked this post
    #243177 quote
    christophe11560
    Participant
    Senior

    Bonjour Ivan,
    J’ai créé un code mais il ne marche pas. Je pense être très proche de la vérité mais je bloque.
    Dans mon code ci-après:
    – 2 sommets consécutifs plus bas
    – 1 clôture de bougie au dessus de la ligne de tendance oblique à la baisse
    – Un text pour localiser où se produit la cassure.

    Pourrais tu me dire où ca cloche et corriger mon erreur?

    merci 😉

    atr=average[20](tr)
    REM definition Sommet 1
    Sommet1 = high[2]<high[1] and high[1]>High[0]
    if Sommet1 then
    x1=barindex[1]
    y1=high[1]
    endif
    REM definition sommet 2
    x2=x1[1]
    y2=y1[1]
    y = y1+(x-x1)*(y2-y1)/(x2-x1)
    x=barindex
    
    if y1<y2 then //(2 sommets consecutifs plus bas)
    if close crosses over y then
    drawtext("bk",x,high+atr,Dialog,Bold,45) coloured(10,153,10)
    endif
    endif
    #243179 quote
    christophe11560
    Participant
    Senior

    Bonjour,
    C’est bon j’ai trouvé le bon code et pour ceux que cela intéresse 😉 voir ci-après:
    Conditions:
    – 2 sommets consécutifs plus bas
    – 1 clôture de bougie au dessus de la ligne de tendance oblique à la baisse
    – Un text pour localiser où se produit la cassure.

    atr=average[20](tr)
    Sommet = high[2]<high[1] and high[1]>High[0]
    if Sommet then
    x1=barindex[1]
    y1=high[1]
    endif
    if sommet then
    x2=x1[1]
    y2=y1[1]
    endif
    x=barindex
    y = y1+(x-x1)*(y2-y1)/(x2-x1)
    if y1<y2 then //(2 sommets consécutifs plus bas)
    if close crosses over y then
    drawtext("bk",x,high+atr,Dialog,Bold,45) coloured(10,153,10)
    endif
    endif
    Iván González thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

breakout ligne de tendance


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by christophe11560
1 year ago.

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