Indicateur Halftrend

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

    Bonjour @ tous,

    est-ce quelqu’un peut me dire si l’indicateur Halftrend existe sur PRT ?

    Peut-etre existe-t-il sous un autre nom ?

    Voici le lien ou on peut le trouver : http://fxprosystems.com/halftrend-analogue-buysellarrowscalper/

    Merci par avance pour vos réponses 🙂

    #21851 quote
    supertiti
    Participant
    Master

    J’ai trouvé ce code à convertir …

    //+———————————————————————-+
    //| HalfTrend.mq4 |
    //| Copyright 2014, FxProSystems.com |
    //+———————————————————————-+
    #property indicator_chart_window
    #property indicator_buffers 6
    #property indicator_color1 DodgerBlue // up[]
    #property indicator_width1 2
    #property indicator_color2 Red // down[]
    #property indicator_width2 2
    #property indicator_color3 DodgerBlue // atrlo[]
    #property indicator_width3 1
    #property indicator_color4 Red // atrhi[]
    #property indicator_width4 1
    #property indicator_color5 DodgerBlue // arrup[]
    #property indicator_width5 1
    #property indicator_color6 Red // arrdwn[]
    #property indicator_width6 1

    extern int Amplitude = 2;
    extern bool ShowBars = true;
    extern bool ShowArrows = true;
    extern bool alertsOn = true;
    extern bool alertsOnCurrent = false;
    extern bool alertsMessage = true;
    extern bool alertsSound = true;
    extern bool alertsEmail = false;

    bool nexttrend;
    double minhighprice,maxlowprice;
    double up[],down[],atrlo[],atrhi[],trend[];
    double arrup[],arrdwn[];
    //+——————————————————————+
    //| |
    //+——————————————————————+
    int init()
    {
    IndicatorBuffers(7); // +1 buffer – trend[]

    SetIndexBuffer(0,up);
    SetIndexStyle(0,DRAW_LINE);
    SetIndexBuffer(1,down);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(2,atrlo);
    SetIndexBuffer(3,atrhi);
    SetIndexBuffer(6,trend);
    SetIndexBuffer(4,arrup);
    SetIndexBuffer(5,arrdwn);
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
    SetIndexEmptyValue(6,0.0);

    if(ShowBars)
    {
    SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_SOLID);
    SetIndexStyle(3,DRAW_HISTOGRAM, STYLE_SOLID);
    }
    else
    {
    SetIndexStyle(2,DRAW_NONE);
    SetIndexStyle(3,DRAW_NONE);
    }
    if(ShowArrows)
    {
    SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID); SetIndexArrow(4,233);
    SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID); SetIndexArrow(5,234);
    }
    else
    {
    SetIndexStyle(4,DRAW_NONE);
    SetIndexStyle(5,DRAW_NONE);
    }

    nexttrend=0;
    minhighprice= High[Bars-1];
    maxlowprice = Low[Bars-1];
    return (0);
    }
    //+——————————————————————+
    //| |
    //+——————————————————————+
    class CFix { } ExtFix;
    //+——————————————————————+
    //| |
    //+——————————————————————+
    int start()
    {
    double atr,lowprice_i,highprice_i,lowma,highma;
    int workbar=0;
    int counted_bars=IndicatorCounted();
    if(counted_bars<0) return(-1);
    if(counted_bars>0) counted_bars–;
    int limit = MathMin(Bars-counted_bars,Bars-1);

    for(int i=Bars-1; i>=0; i–)
    {
    lowprice_i=iLow(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_LOW,Amplitude,i));
    highprice_i=iHigh(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_HIGH,Amplitude,i));
    lowma=NormalizeDouble(iMA(NULL,0,Amplitude,0,MODE_SMA,PRICE_LOW,i),Digits());
    highma=NormalizeDouble(iMA(NULL,0,Amplitude,0,MODE_SMA,PRICE_HIGH,i),Digits());
    trend[i]=trend[i+1];
    atr=iATR(Symbol(),0,100,i)/2;

    arrup[i] = EMPTY_VALUE;
    arrdwn[i] = EMPTY_VALUE;
    if(nexttrend==1)
    {
    maxlowprice=MathMax(lowprice_i,maxlowprice);

    if(highma<maxlowprice && Close[i]<Low[i+1])
    {
    trend[i]=1.0;
    nexttrend=0;
    minhighprice=highprice_i;
    }
    }
    if(nexttrend==0)
    {
    minhighprice=MathMin(highprice_i,minhighprice);

    if(lowma>minhighprice && Close[i]>High[i+1])
    {
    trend[i]=0.0;
    nexttrend=1;
    maxlowprice=lowprice_i;
    }
    }
    if(trend[i]==0.0)
    {
    if(trend[i+1]!=0.0)
    {
    up[i]=down[i+1];
    up[i+1]=up[i];
    arrup[i] = up[i] – 2*atr;
    }
    else
    {
    up[i]=MathMax(maxlowprice,up[i+1]);
    }
    atrhi[i] = up[i] – atr;
    atrlo[i] = up[i];
    down[i]=0.0;
    }
    else
    {
    if(trend[i+1]!=1.0)
    {
    down[i]=up[i+1];
    down[i+1]=down[i];
    arrdwn[i] = down[i] + 2*atr;
    }
    else
    {
    down[i]=MathMin(minhighprice,down[i+1]);
    }
    atrhi[i] = down[i] + atr;
    atrlo[i] = down[i];
    up[i]=0.0;
    }
    }
    manageAlerts();
    return (0);
    }
    //+——————————————————————+
    //+——————————————————————-
    //|
    //+——————————————————————-
    //
    //
    //
    //
    //

    void manageAlerts()
    {
    if (alertsOn)
    {
    if (alertsOnCurrent)
    int whichBar = 0;
    else whichBar = 1;
    if (arrup[whichBar] != EMPTY_VALUE) doAlert(whichBar,”up”);
    if (arrdwn[whichBar] != EMPTY_VALUE) doAlert(whichBar,”down”);
    }
    }

    //
    //
    //
    //
    //

    void doAlert(int forBar, string doWhat)
    {
    static string previousAlert=”nothing”;
    static datetime previousTime;
    string message;

    if (previousAlert != doWhat || previousTime != Time[forBar]) {
    previousAlert = doWhat;
    previousTime = Time[forBar];

    //
    //
    //
    //
    //

    message = StringConcatenate(Symbol(),” at “,TimeToStr(TimeLocal(),TIME_SECONDS),” HalfTrend signal “,doWhat);
    if (alertsMessage) Alert(message);
    if (alertsEmail) SendMail(StringConcatenate(Symbol(),”HalfTrend “),message);
    if (alertsSound) PlaySound(“alert2.wav”);
    }
    }

    #22057 quote
    zilliq
    Participant
    Master

    Cela semble assez proche d’un supertrend, mais avec un blocage à 2ATR …

    A comparer sur MT4 pour confirmation

    Zilliq

    #28133 quote
    Nicolas
    Keymaster
    Master

    L’indicateur en question a été convertit vers prorealtime. Dans la bibliothèque: HalfTrend prorealtime , vous trouverez un ensemble de différentes modifications de celui-ci en complément. Bon amusement.

    #28137 quote
    leyoy
    Participant
    Senior

    Super. Merci beaucoup 🙂

    #34685 quote
    leyoy
    Participant
    Senior

    Bonjour,

    j’aimerais programmer un p’tit truc sur PRT mais j’avoue je ne sais pas comment faire.

    J’ai mis une couleur verte quand la HT monte et une rouge quand la HT descend.

    Comment cela se représente en programmation PRT ?

    Sais pas si suis très clair :/

    Merci par avance pour ta réponse. 🙂

    #34687 quote
    Nicolas
    Keymaster
    Master

    Il y a 2 méthodes, soit avec COLOURED BY ou en utilisant des valeurs RGB dynamique dans le rendu de la variable de la fonction RETURN:

    Méthode 1:

    (ici on admet que la variable à tester pour savoir si ça monte ou descend s’appelle HT1)

    if HT>HT[1] then 
     color = 1
    elsif HT<HT[1] then 
     color = -1
    endif
    
    RETURN HT coloured by color

    Pour ce premier exemple, il faudra bien entendu choisir la couleur soit même dans l’onglet de propriété de l’indicateur pour “monter / descente” (j’utilise une plateforme en anglais, je ne suis plus certain du terme exacte, voir image).

    Méthode 2:

    On utilise un RGB dynamique, pour déterminer la couleur que tu souhaites, et là plus besoin de modifier ensuite dans la fenêtre de propriété:

    if HT>HT[1] then 
     colorR=0
     colorG=100
     colorB=0
    elsif HT<HT[1] then 
     colorR=100
     colorG=0
     colorB=0
    endif
    
    RETURN HT coloured(colorR,colorG,colorB)
    couleur-indicateur-prorealtime-uptrend-downtrend.png couleur-indicateur-prorealtime-uptrend-downtrend.png
    #34691 quote
    leyoy
    Participant
    Senior

    oh merci beaucoup la réponse rapide.

    Bon je vais essayer d’en faire quelque chose … et la c’est pas gagné ! :p

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

Indicateur Halftrend


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
leyoy @lionel_delamour Participant
Summary

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

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 01/19/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...