MT5 to PRT

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36629 quote
    Plscap
    Participant
    Veteran

    Bonjour à tous et bonjour à toi Nicolas,

    Je me permets de créer ce topic pour savoir si quelqu’un aurait possibilité (et la grande amabilité)

    de transformer un indicateur MT5 en PRT.
    Voici le code de l’indicateur

    #property indicator_separate_window
    #property indicator_buffers 3
    #property indicator_plots   3
    //--- plot InClose
    #property indicator_label1  "In Close"
    #property indicator_type1   DRAW_LINE
    #property indicator_color1  clrRed
    #property indicator_style1  STYLE_SOLID
    #property indicator_width1  2
    //--- plot OutClose
    #property indicator_label2  "Out Close"
    #property indicator_type2   DRAW_LINE
    #property indicator_color2  clrBlueViolet
    #property indicator_style2  STYLE_SOLID
    #property indicator_width2  2
    //--- plot DirectClose
    #property indicator_label3  "Direct Close"
    #property indicator_type3   DRAW_LINE
    #property indicator_color3  clrWhite
    #property indicator_style3  STYLE_SOLID
    #property indicator_width3  2
    //--- indicator levels
    #property indicator_level1 0
    #property indicator_level2 3
    #property indicator_level3 -3
    #property indicator_levelcolor clrGray
    //--- indicator buffers
    double         InCloseBuffer[];
    double         OutCloseBuffer[];
    double         DirectCloseBuffer[];
    //--- global variables
    int            minRequiredBars;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int OnInit() {
    //---
       minRequiredBars = 1;
    //--- indicator buffers mapping
       SetIndexBuffer(0, InCloseBuffer, INDICATOR_DATA);
       SetIndexBuffer(1, OutCloseBuffer, INDICATOR_DATA);
       SetIndexBuffer(2, DirectCloseBuffer, INDICATOR_DATA);
    //---
       for ( int i = 0; i < 3; i++ ) {
          PlotIndexSetInteger(i, PLOT_DRAW_BEGIN, minRequiredBars);
          PlotIndexSetInteger(i, PLOT_SHIFT, 0);
          PlotIndexSetDouble(i, PLOT_EMPTY_VALUE, EMPTY_VALUE);
       }
    //---
       IndicatorSetInteger(INDICATOR_DIGITS, 0);
    //---
       IndicatorSetString(INDICATOR_SHORTNAME, "Close Series");
    //---
       return(0);
    }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int OnCalculate(const int rates_total,
                    const int prev_calculated,
                    const datetime &time[],
                    const double &open[],
                    const double &high[],
                    const double &low[],
                    const double &close[],
                    const long &tick_volume[],
                    const long &volume[],
                    const int &spread[])
    {
    //---
       int startBar;
    //---
       if ( rates_total < minRequiredBars ) {
          Print("Íåäîñòàòî÷íî áàðîâ äëÿ ðàñ÷¸òà.");
          return(0);
       }
    //---
       if ( prev_calculated > rates_total || prev_calculated <= 0 ) {
          startBar = minRequiredBars;
          for ( int bar = 0; bar < minRequiredBars; bar++ ) {
             InCloseBuffer[bar] = 0.0;
             OutCloseBuffer[bar] = 0.0;
             DirectCloseBuffer[bar] = 0.0;
          }
       } else {
          startBar = prev_calculated - 1;
       }
    //---
       for ( int bar = startBar; bar < rates_total && !IsStopped(); bar++ ) {
          int prevBar = bar - 1;
          //---
          if ( close[bar] <= high[prevBar] && close[bar] >= low[prevBar] ) {
             if ( InCloseBuffer[prevBar] > 0 ) {
                InCloseBuffer[bar] = InCloseBuffer[prevBar] + 1;
             } else {
                InCloseBuffer[bar] = 1;
             }
          } else {
             InCloseBuffer[bar] = 0;
          }
          //---
          if ( open[bar] > high[prevBar] ) {
             if ( OutCloseBuffer[prevBar] > 0 ) {
                OutCloseBuffer[bar] = OutCloseBuffer[prevBar] + 1;
             } else {
                OutCloseBuffer[bar] = 1;
             }
          } else if (open[bar] < low[prevBar] ) {
             if ( OutCloseBuffer[prevBar] < 0 ) {
                OutCloseBuffer[bar] = OutCloseBuffer[prevBar] - 1;
             } else {
                OutCloseBuffer[bar] = -1;
             }
          } else {
             OutCloseBuffer[bar] = 0;
          }
          //---
          if ( close[bar] > open[bar] ) {
             if ( DirectCloseBuffer[prevBar] > 0 ) {
                DirectCloseBuffer[bar] = DirectCloseBuffer[prevBar] + 1;
             } else {
                DirectCloseBuffer[bar] = 1;
             }
          } else if ( close[bar] < open[bar] ) {
             if ( DirectCloseBuffer[prevBar] < 0 ) {
                DirectCloseBuffer[bar] = DirectCloseBuffer[prevBar] - 1;
             } else {
                DirectCloseBuffer[bar] = -1;
             }
          } else {
             DirectCloseBuffer[bar] = 0;
          }
       }
    //--- return value of prev_calculated for next call
       return(rates_total);
    }
    //+------------------------------------------------------------------+
    

    Un grand merci d’avance 🙂

    #36676 quote
    Nicolas
    Keymaster
    Master

    L’indicateur a-t’il un nom ? A quoi ressemble t’il ? des copies d’écrans sont toujours grandement apprécié, merci ! Le code semble être toujours du mq4 et non du MQL5.

    #36692 quote
    Plscap
    Participant
    Veteran

    Bonjour Nicolas,

    L’indicateur s’appelle CloseSeries et voici quelques captures pour avoir une idée de l’indicateur.

    Il est très utile lorsqu’il atteint les niveaux (niveaux que l’on peut bien entendu regler à sa guise)

    Capture-d’écran-2017-05-26-à-11.43.56.png Capture-d’écran-2017-05-26-à-11.43.56.png Capture-d’écran-2017-05-26-à-11.42.56.png Capture-d’écran-2017-05-26-à-11.42.56.png
    #36912 quote
    Nicolas
    Keymaster
    Master

    Merci pour les informations, voilà ce que ça peut donner (ci-joint). Pourrais-tu me donner quelques explications pour son ajout à la bibliothèque de codes stp ?

    #36921 quote
    Nicolas
    Keymaster
    Master

    L’indicateur est désormais disponible au téléchargement dans notre bibliothèque juste ici :

    Close Series

    #37099 quote
    Plscap
    Participant
    Veteran

    Bonjour Nicolas,

    Un  grand merci pour l’indicateur c’est parfaitement ça.

    Alors cet indicateur moi je m’en sers sur des petites UT, essentiellement pour déterminer quand le cours va se retourner. pour ça j’attends que que la courbe Directclose atteigne un des niveaux.

    Niveaux que je règle en fonction du marché, si marché sans tendance, niveaux plutôt serrés sinon niveaux un peu plus large

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

MT5 to PRT


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Plscap @flodefacebook Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Plscap
8 years, 9 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/25/2017
Status: Active
Attachments: 2 files
Logo Logo
Loading...