Demande d’information sur l’indicateur hypertrend

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #245495 quote
    Samir pluquinSamir pluquin
    Participant
    Junior
    Bonjour a tous la communauté, j’ai un souci avec le code de l’indicateur hypertrend, je souhaiterais déclencher un achat lorsque la bougie en cours est en dessous de la barre de l’indicateur et déclencher une vente lorsque la bougie en cours est au dessus de la barre de l’indicateur Pouvez vous m’aider a coder cela svp merci beaucoup ci dessous le code source de l’indicateur ////////code hypertrend ////////// //PRC_Q-Trend | indicator //17.07.23 //Nicolas @ http://www.prorealcode.com //Sharing ProRealTime knowledge // —settings //p = 200 //Trend period //atrp = 14 //ATR Period //mult = 1.0 //ATR Multiplier //mode = 1 //Signal mode options = [1=”Type A”, 2=”Type B”] //useemasmoother = 0 //Smooth source with EMA? 0=false ; 1=true //srcemaperiod = 3 //EMA Smoother period //colorbars = 0 //Color bars? 0=false ; 1=true //signalsview = 0 //0 = trend inversion ; 1 = strong buy / strong sell only // — end of settings source = customclose // Calculations if useemasmoother then src = average[srcemaperiod,1](source) else src=source endif hh = highest[p](src) // Highest of src p-bars back; ll = lowest[p](src) // Lowest of src p-bars back. d = hh – ll if barindex>p then once m = (hh + ll) / 2 // Initial trend line; atr = AverageTrueRange[atrp][1] // ATR; epsilon = mult * atr // Epsilon is a mathematical variable used in many different theorems in order to simplify work with mathematical object. Here it used as sensitivity measure. if mode=2 then //type B changeup = src crosses over m+epsilon or src crosses under m+epsilon changedown = src crosses over m-epsilon or src crosses under m-epsilon else changeup = src crosses over m+epsilon or src > m+epsilon changedown = src crosses under m-epsilon or src < m-epsilon endif sb = open < ll + d / 8 and open >= ll ss = open > hh – d / 8 and open <= hh strongbuy = sb or sb[1] or sb[2] or sb[3] or sb[4] strongsell = ss or ss[1] or ss[2] or ss[3] or ss[4] if (changeup or changedown) then if changeup then m=m + epsilon elsif changedown then m=m – epsilon endif else m=m[1] endif if changeup then r=0 g=255 elsif changedown then r=255 g=0 endif if colorbars then drawcandle(open,high,low,close)coloured(r,g,0) endif if signalsview=1 then if strongbuy and ls<>1 then drawtext(“▲”,barindex,low) coloured(“lime”) ls=1 endif if strongsell and ls<>-1 then drawtext(“▼”,barindex,high) coloured(“red”) ls=-1 endif else if r<>r[1]and r>0 then drawtext(“▼”,barindex[1],m[1]) coloured(“red”) endif if r<>r[1]and r=0 then drawtext(“▲”,barindex[1],m[1]) coloured(“lime”) endif endif endif RETURN m style(line,3) coloured(r,g,0)
    #245502 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Bonjour,

    Si j’ai bien compris, vous souhaitez déclencher un achat lorsque toute la bougie se trouve en dessous de la ligne de l’indicateur HyperTrend (c’est-à-dire lorsque le plus haut de la bougie est inférieur à la ligne), et une vente lorsque toute la bougie se trouve au-dessus de cette ligne (c’est-à-dire lorsque le plus bas est supérieur à la ligne).

    Dans ce cas, vous pouvez utiliser une logique très simple comme celle-ci :

    // Achat lorsque toute la bougie est sous la ligne de l’indicateur
    IF high < m THEN
        BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Vente lorsque toute la bougie est au-dessus de la ligne de l’indicateur
    IF low > m THEN
        SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    Si vous souhaitez qu’un seul achat soit effectué, vous devrez ajouter cette ligne au début du code :
    defparam cumulateorders = false
    Ou bien, vous pouvez modifier la condition comme ceci :
    IF NOT onmarket AND high < m THEN
    Samir pluquin thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Demande d’information sur l’indicateur hypertrend


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
1 year, 7 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 04/01/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...