English Русский 中文 Español Deutsch 日本語 Português 한국어 Italiano Türkçe
Migration de MQL4 vers MQL5

Migration de MQL4 vers MQL5

MetaTrader 5Exemples | 17 novembre 2021, 15:04
958 0
Sergey Pavlov
Sergey Pavlov

Introduction

De nombreux développeurs ont accumulé de nombreux indicateurs et stratégies de trading rédigés en MQL4. Pour les utiliser dans Metatrader 5, ils doivent être convertis en MQL5. Ce n'est pas si facile de réécrire tous les programmes en MQL5. Il serait beaucoup plus facile de les convertir, s'il y avait une traduction-référence, et meilleur avec des exemples.

Dans cet article, je voudrais suggérer ma version d'un guide pour migrer de MQL4 vers MQL5.

1. Périodes du graphique

Dans le graphique MQL5, les constantes de période ont changé et de nouvelles périodes de temps (M2, M3, M4, M6, M10, M12, H2, H3, H6, H8, H12) ont été ajoutées. Pour convertir des cadences de temps MQL4, vous pouvez utiliser la fonction suivante :

ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      
      default: return(PERIOD_CURRENT);
     }
  }

Il convient de noter que dans MQL5 les valeurs numériques des constantes du période du graphique (à partir de H1) ne sont pas égales au nombre de minutes d'une barre (par exemple, dans MQL5, la valeur numérique de la constante PERIOD_H1=16385, mais dans MQL4 PERIOD_H1 =60). Vous devez en tenir compte lors de la conversion en MQL5, si les valeurs numériques des constantes MQL4 sont utilisées dans les programmes MQL4.

Pour déterminer le nombre de minutes de la période indiquée du graphique, divisez la valeur renvoyée par la fonction PeriodSeconds par 60.

2. Déclarer les Constantes

Certaines des constantes MQL4 standard sont absentes dans MQL5, elles doivent donc être déclarées :

//+------------------------------------------------------------------+
//|                                                     InitMQL4.mqh |
//|                                                 Copyright DC2008 |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "keiji"
#property copyright "DC2008"
#property link      "https://www.mql5.com"
//--- Declaration of constants
#define OP_BUY 0           //Buy 
#define OP_SELL 1          //Sell 
#define OP_BUYLIMIT 2      //Pending order of BUY LIMIT type 
#define OP_SELLLIMIT 3     //Pending order of SELL LIMIT type 
#define OP_BUYSTOP 4       //Pending order of BUY STOP type 
#define OP_SELLSTOP 5      //Pending order of SELL STOP type 
//---
#define MODE_OPEN 0
#define MODE_CLOSE 3
#define MODE_VOLUME 4 
#define MODE_REAL_VOLUME 5
#define MODE_TRADES 0
#define MODE_HISTORY 1
#define SELECT_BY_POS 0
#define SELECT_BY_TICKET 1
//---
#define DOUBLE_VALUE 0
#define FLOAT_VALUE 1
#define LONG_VALUE INT_VALUE
//---
#define CHART_BAR 0
#define CHART_CANDLE 1
//---
#define MODE_ASCEND 0
#define MODE_DESCEND 1
//---
#define MODE_LOW 1
#define MODE_HIGH 2
#define MODE_TIME 5
#define MODE_BID 9
#define MODE_ASK 10
#define MODE_POINT 11
#define MODE_DIGITS 12
#define MODE_SPREAD 13
#define MODE_STOPLEVEL 14
#define MODE_LOTSIZE 15
#define MODE_TICKVALUE 16
#define MODE_TICKSIZE 17
#define MODE_SWAPLONG 18
#define MODE_SWAPSHORT 19
#define MODE_STARTING 20
#define MODE_EXPIRATION 21
#define MODE_TRADEALLOWED 22
#define MODE_MINLOT 23
#define MODE_LOTSTEP 24
#define MODE_MAXLOT 25
#define MODE_SWAPTYPE 26
#define MODE_PROFITCALCMODE 27
#define MODE_MARGINCALCMODE 28
#define MODE_MARGININIT 29
#define MODE_MARGINMAINTENANCE 30
#define MODE_MARGINHEDGED 31
#define MODE_MARGINREQUIRED 32
#define MODE_FREEZELEVEL 33
//---
#define EMPTY -1
Note: Les constantes dans MQl4 et MQL5 diffèrent, il est donc préférable de les déclarer dans un fichier séparé initMQ4.mqh pour une utilisation ultérieure.

3. Variables prédéfinies

MQL4
 MQL5Description
double Ask
MqlTick last_tick;
SymbolInfoTick(_Symbol,last_tick);
double Ask=last_tick.ask;
Ask
Le dernier prix demandé connu pour le symbole actuel.
SymbolInfoTick
int Bars
int Bars=Bars(_Symbol,_Period);
Bars
Nombre de barres dans le graphique actuel.
Barres
double Bid
MqlTick last_tick;
SymbolInfoTick(_Symbol,last_tick);
double Bid=last_tick.bid;
Bid
Le dernier prix acheteur connu du symbole actuel.
SymbolInfoTick
double Close[]
double Close[];
int count;   // number of elements to copy
ArraySetAsSeries(Close,true);
CopyClose(_Symbol,_Period,0,count,Close);
Close
Tableau de séries qui comporte les prix de clôture pour chaque barre du graphique actuel.
CopyClose, ArraySetAsSeries
int Digits
int Digits=_Digits;
Digits
Nombre de chiffres après la virgule pour les prix des symboles actuels.
_Digits

double High[]
double High[];
int count;   // number of elements to copy
ArraySetAsSeries(High,true);
CopyHigh(_Symbol,_Period,0,count,High);
High
Tableau de séries qui comporte les prix les plus élevés de chaque barre du graphique actuel.
CopyHigh, ArraySetAsSeries
double Low[]
double Low[];
int count;   // number of elements to copy
ArraySetAsSeries(Low,true);
CopyLow(_Symbol,_Period,0,count,Low);
Low
Tableau de séries qui comporte les prix les plus bas de chaque barre du graphique actuel.
CopyLow, ArraySetAsSeries
double Open[]
double Open[];
int count;   // number of elements to copy
ArraySetAsSeries(Open,true);
CopyOpen(_Symbol,_Period,0,count,Open);
Open
Tableau de séries qui comporte les prix d'ouverture de chaque barre du graphique actuel.
CopyOpen, ArraySetAsSeries
double Point
double Point=_Point;
Point
La valeur actuelle du point de symbole dans la monnaie e de cotation.
_Point
datetime Time[]
datetime Time[];
int count;   // number of elements to copy
ArraySetAsSeries(Time,true);
CopyTime(_Symbol,_Period,0,count,Time);
Time
Tableau de séries qui comporte le temps d'ouverture de chaque barre du graphique actuel. Des données telles que datetime représentent le temps, en secondes, qui s'est écoulé depuis 00h00 du 1er janvier 1970.
CopyTime, ArraySetAsSeries
double Volume[]
long Volume[];
int count;   // number of elements to copy
ArraySetAsSeries(Volume,true);
CopyTickVolume(_Symbol,_Period,0,count,Volume);
Volume
Tableau de séries qui comporte les volumes de graduation de chaque barre du graphique actuel.
CopyTickVolume, ArraySetAsSeries


4. Informations sur le compte

MQL4
MQL5
Description
double AccountBalance()
double AccountInfoDouble(ACCOUNT_BALANCE)
AccountBalance
Renvoie la valeur du solde du compte courant (le montant d'argent sur le compte).
AccountInfoDouble
double AccountCredit()
double AccountInfoDouble(ACCOUNT_CREDIT)
AccountCredit
Renvoie la valeur du crédit du compte courant.
AccountInfoDouble
string AccountCompany()
string AccountInfoString(ACCOUNT_COMPANY)
AccountCompany
Renvoie le nom de la société de courtage où le compte courant a été enregistré.
CompteInfoString
string AccountCurrency()
string AccountInfoString(ACCOUNT_CURRENCY)
AccountCurrency
Renvoie le nom de la monnaie du compte courant.
CompteInfoString
double AccountEquity()
double AccountInfoDouble(ACCOUNT_EQUITY)
AccountEquity
Renvoie la valeur nette du compte courant. Le calcul des capitaux propres dépend des paramètres du serveur de trading.
AccountInfoDouble
double AccountFreeMargin()
double AccountInfoDouble(ACCOUNT_FREEMARGIN)
AccountFreeMargin
Renvoie la valeur de la marge libre du compte courant.
AccountInfoDouble
double AccountFreeMarginCheck(string symbol,
                              int cmd,
                              double volume)
-
AccountFreeMarginCheck
Renvoie la marge libre qui reste après l'ouverture de la position indiquée au prix actuel sur le compte courant.
double AccountFreeMarginMode()
-
AccountFreeMarginMode
Mode de calcul de la marge libre autorisée pour ouvrir des positions sur le compte courant.
int AccountLeverage()
int AccountInfoInteger(ACCOUNT_LEVERAGE)
AccountLeverage
Renvoie l'effet de levier du compte courant.
AccountInfoInteger
double AccountMargin()
double AccountInfoDouble(ACCOUNT_MARGIN)
AccountMargin
Renvoie la valeur de la marge du compte courant.
AccountInfoDouble
string AccountName()
string AccountInfoString(ACCOUNT_NAME)
AccountName
Renvoie le nom du compte actuel.
CompteInfoString
int AccountNumber()
int AccountInfoInteger(ACCOUNT_LOGIN)
AccountNumber
Renvoie le numéro du compte courant.
AccountInfoInteger
double AccountProfit()
double AccountInfoDouble(ACCOUNT_PROFIT)
AccountProfit
Renvoie la valeur de profit du compte courant.
AccountInfoDouble
string AccountServer()
string AccountInfoString(ACCOUNT_SERVER)
AccountServer
Renvoie le nom du serveur connecté.
CompteInfoString
int AccountStopoutLevel()
double AccountInfoDouble(ACCOUNT_MARGIN_SO_SO)
AccountStopoutLevel
Renvoie la valeur du niveau Stop Out.
AccountInfoDouble
int AccountStopoutMode()
int AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE)
AccountStopoutMode
Renvoie le mode de calcul du niveau Stop Out.
AccountInfoInteger


5. Fonctions de tableau

MQL4
MQL5
 Description
int ArrayBsearch(double array[],
                 double value,
                 int count=WHOLE_ARRAY,
                 int start=0,
                 int direction=MODE_ASCEND)
int ArrayBsearch(double    array[],
                 double    searched_value
                 )
ArrayBsearch
La fonction recherche une valeur indiquée dans un tableau numérique à une dimension.
ArrayBsearch
int ArrayCopy(object&dest[],
              object source[],
              int start_dest=0,
              int start_source=0,
              int count=WHOLE_ARRAY)
int ArrayCopy(void  dst_array[],
              void  src_array[],
              int   dst_start=0,
              int   src_start=0,
              int   cnt=WHOLE_ARRAY
              )
ArrayCopy
Copie un tableau dans un autre. Les tableaux doivent être du même type, mais les tableaux de type double[], int[], datetime[], color[] et bool[] peuvent être copiés en tant que tableaux du même type. Retourne le nombre d'éléments copiés.
ArrayCopy
int ArrayCopyRates(double&dest_array[],
                   string symbol=NULL,
                   int timeframe=0)
-ArrayCopyRates
Copie les données des barres du graphique en cours dans le tableau bidimensionnel de type RateInfo[][6] et renvoie la quantité de barres copiées, ou -1 en cas d'échec.
int ArrayCopySeries(double&array[],
                    int series_index,
                    string symbol=NULL,
                    int timeframe=0)
int ArrayCopySeriesMQL4(double &array[],
                        int series_index,
                        string symbol=NULL,
                        int tf=0)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int count=Bars(symbol,timeframe);
   switch(series_index)
     {
      case MODE_OPEN:
         return(CopyOpen(symbol,timeframe,0,count,array));
      case MODE_LOW:
         return(CopyLow(symbol,timeframe,0,count,array));
      case MODE_HIGH:
         return(CopyHigh(symbol,timeframe,0,count,array));
      case MODE_CLOSE:
         return(CopyClose(symbol,timeframe,0,count,array));

      default: return(0);
     }
   return(0);
  }
ArrayCopySeries
Copie un tableau de séries chronologiques dans un tableau personnalisé et renvoie le nombre d'éléments copiés.
CopyOpen, CopyLow, CopyHigh, CopyClose, Bars
int ArrayDimension( object array[])
-ArrayDimension
Renvoie le rang du tableau multidimensionnel.
bool ArrayGetAsSeries( object array[])
bool ArrayGetAsSeries(void  array)
ArrayGetAsSeries
Renvoie TRUE si un tableau est organisé comme un tableau de séries chronologiques (les éléments du tableau sont indexés du dernier au premier), sinon renvoie FALSE.
ArrayGetAsSeries
int ArrayInitialize(double &array[],
                    double value)
int ArrayInitializeMQL4(double &array[],
                        double value)
  {
   ArrayInitialize(array,value);
   return(ArraySize(array));
  }
ArrayInitialize
Définit tous les éléments d'un tableau numérique à la même valeur. Renvoie le nombre d'éléments initialisés.
ArrayInitialize, ArraySize
bool ArrayIsSeries( object array[])
bool ArrayIsSeries(void  array[])
ArrayIsSeries
Renvoie TRUE si le tableau sous contrôle est un tableau de séries chronologiques (Time[],Open[],Close[],High[],Low[] ou Volume[]), sinon renvoie FALSE.
ArrayIsSeries
int ArrayMaximum(double array[],
                 int count=WHOLE_ARRAY,
                 int start=0)
int ArrayMaximumMQL4(double &array[],
                     int count=WHOLE_ARRAY,
                     int start=0)
  {
   return(ArrayMaximum(array,start,count));
  }
ArrayMaximum
Recherche l'élément avec la valeur maximale. La fonction renvoie la position de cet élément maximal dans le tableau.
ArrayMaximum
int ArrayMinimum(double array[],
                 int count=WHOLE_ARRAY,
                 int start=0)
int ArrayMinimumMQL4(double &array[],
                     int count=WHOLE_ARRAY,
                     int start=0)
  {
   return(ArrayMinimum(array,start,count));
  }
ArrayMinimum
Recherche l'élément avec la valeur minimale. La fonction renvoie la position de cet élément minimal dans le tableau.
ArrayMinimum
int ArrayRange(object array[],
               int range_index)
int ArrayRange(void  array[],
               int   rank_index
               )
ArrayRange
Renvoie le nombre d'éléments dans la dimension donnée du tableau.
ArrayRange
int ArrayResize(object &array[],
                int new_size)
int ArrayResize(void  array[],
                int   new_size,
                int   allocated_size=0
                )
ArrayResize
Définit une nouvelle taille pour la première dimension.
ArrayResize
bool ArraySetAsSeries(double &array[],
                      bool set)
bool ArraySetAsSeries(void  array[],
                      bool  set
                      )
ArraySetAsSeries
Renvoie le nombre d'éléments dans la dimension donnée du tableau. Étant donné que les index sont de base zéro, la taille de la dimension est supérieure de 1 au plus grand index.
ArraySetAsSeries
int ArraySize( object array[])
int ArraySize(void  array[])
ArraySize
Renvoie le nombre d'éléments contenus dans le tableau.
ArraySize
int ArraySort(double &array[],
              int count=WHOLE_ARRAY,
              int start=0,
              int sort_dir=MODE_ASCEND)
int ArraySortMQL4(double &array[],
                  int count=WHOLE_ARRAY,
                  int start=0,
                  int sort_dir=MODE_ASCEND)
  {
   switch(sort_dir)
     {
      case MODE_ASCEND:
         ArraySetAsSeries(array,true);
      case MODE_DESCEND:
         ArraySetAsSeries(array,false);

      default: ArraySetAsSeries(array,true);
     }
   ArraySort(array);
   return(0);
  }
ArraySort
Trie les tableaux numériques par première dimension. Les tableaux de séries ne peuvent pas être triés par ArraySort().
ArraySort, ArraySetAsSeries


6. Examen

MQL4
MQL5
Description
int GetLastError()
int GetLastError()
GetLastError
La fonction renvoie la dernière erreur survenue, puis la valeur de la variable spéciale last_error où le dernier code d'erreur est stocké sera mise à zéro.
GetLastError
bool IsConnected()
bool TerminalInfoInteger(TERMINAL_CONNECTED)
IsConnected
La fonction retourne l'état de la connexion principale entre le terminal client et le serveur qui effectue le pompage des données. Il renvoie VRAI si la connexion au serveur a été établie avec succès, sinon, il renvoie FAUX.
TerminalInfoInteger
bool IsDemo()
bool IsDemoMQL4()
  {
   if(AccountInfoInteger(ACCOUNT_TRADE_MODE)==ACCOUNT_TRADE_MODE_DEMO)
      return(true);
   else
      return(false);
  }
IsDemo
Renvoie TRUE si l'expert s'exécute sur un compte démo, sinon renvoie FALSE.
AccountInfoInteger
bool IsDllsAllowed()
bool TerminalInfoInteger(TERMINAL_DLLS_ALLOWED)
IsDllsAllowed
Renvoie TRUE si l'appel de DLL de fonction est autorisé pour l'Expert Advisor, sinon renvoie FALSE.
TerminalInfoInteger
bool IsExpertEnabled()
bool AccountInfoInteger(ACCOUNT_TRADE_EXPERT)
IsExpertEnabled
Renvoie TRUE si l'utilisation des Expert Advisors est activée dans le terminal client, sinon renvoie FALSE.
AccountInfoInteger
bool IsLibrariesAllowed()
bool MQLInfoInteger(MQL5_DLLS_ALLOWED)
IsLibrariesAllowed
Renvoie TRUE si un Expert Advisor peut appeler la fonction de bibliothèque, sinon renvoie FALSE.
MQLInfoInteger
bool IsOptimization()
bool MQLInfoInteger(MQL5_OPTIMIZATION)
IsOptimization
Renvoie TRUE si un Expert Advisor s'exécute dans le mode d'optimisation du testeur de stratégie, sinon renvoie FALSE.
MQLInfoInteger
bool IsStopped()
bool IsStopped()
IsStopped
Renvoie TRUE si le programme (un Expert Advisor ou un script) a reçu l'ordre d'interrompre son opération, sinon renvoie FALSE.
IsStopped
bool IsTesting()
bool MQLInfoInteger(MQL5_TESTING)
IsTesting
Renvoie TRUE si un Expert Advisor s'exécute en mode test, sinon renvoie FALSE.
MQLInfoInteger
bool IsTradeAllowed()
bool MQLInfoInteger(MQL5_TRADE_ALLOWED)
IsTradeAllowed
Renvoie TRUE si le trading par Expert Advisors est autorisé et qu'un thread pour le trading n'est pas occupé, sinon renvoie FALSE.
MQLInfoInteger
bool IsTradeContextBusy()
-IsTradeContextBusy
Renvoie TRUE si un thread de trading est occupé par un autre Expert Advisor, sinon renvoie FALSE.
bool IsVisualMode()
bool MQLInfoInteger(MQL5_VISUAL_MODE)
IsVisualMode
Renvoie TRUE si l'Expert Advisor est testé avec le bouton "Visual Mode" coché, sinon renvoie FALSE.
MQLInfoInteger
int UninitializeReason()
int UninitializeReason()
UninitializeReason
Renvoie le code du motif de la désinitialisation pour les Expert Advisors, les indicateurs personnalisés et les scripts.
UninitializeReason


7. Terminal client

MQL4
 MQL5 Description
string TerminalCompany()
string TerminalInfoString(TERMINAL_COMPANY)
TerminalCompany
Renvoie le nom de la société propriétaire du terminal client.
TerminalInfoString
string TerminalName()
string TerminalInfoString(TERMINAL_NAME)
TerminalName
Renvoie le nom du terminal client.
TerminalInfoString
string TerminalPath()
string TerminalInfoString(TERMINAL_PATH)
TerminalPath
Renvoie le répertoire à partir duquel le terminal client a été lancé.
TerminalInfoString


8. Fonctions communes

MQL4
MQL5
Description
void Alert(...)
void Alert(argument,...)
Alert
Affiche une boîte de dialogue comportant les données définies par l'utilisateur. Les paramètres peuvent être de n'importe quel type.
Alerte
void Comment(...)
void Comment(argument,...)
Comment
La fonction affiche le commentaire défini par l'utilisateur dans le coin supérieur gauche du graphique.
Commentaire
int GetTickCount()
uint GetTickCount()
GetTickCount
La fonction GetTickCount() récupère le nombre de millisecondes écoulées depuis le démarrage du système.
GetTickCount
double MarketInfo(string symbol,
                  int type)
double MarketInfoMQL4(string symbol,
                      int type)
  {
   switch(type)
     {
      case MODE_LOW:
         return(SymbolInfoDouble(symbol,SYMBOL_LASTLOW));
      case MODE_HIGH:
         return(SymbolInfoDouble(symbol,SYMBOL_LASTHIGH));
      case MODE_TIME:
         return(SymbolInfoInteger(symbol,SYMBOL_TIME));
      case MODE_BID:
         return(Bid);
      case MODE_ASK:
         return(Ask);
      case MODE_POINT:
         return(SymbolInfoDouble(symbol,SYMBOL_POINT));
      case MODE_DIGITS:
         return(SymbolInfoInteger(symbol,SYMBOL_DIGITS));
      case MODE_SPREAD:
         return(SymbolInfoInteger(symbol,SYMBOL_SPREAD));
      case MODE_STOPLEVEL:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL));
      case MODE_LOTSIZE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_CONTRACT_SIZE));
      case MODE_TICKVALUE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE));
      case MODE_TICKSIZE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE));
      case MODE_SWAPLONG:
         return(SymbolInfoDouble(symbol,SYMBOL_SWAP_LONG));
      case MODE_SWAPSHORT:
         return(SymbolInfoDouble(symbol,SYMBOL_SWAP_SHORT));
      case MODE_STARTING:
         return(0);
      case MODE_EXPIRATION:
         return(0);
      case MODE_TRADEALLOWED:
         return(0);
      case MODE_MINLOT:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN));
      case MODE_LOTSTEP:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP));
      case MODE_MAXLOT:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_MAX));
      case MODE_SWAPTYPE:
         return(SymbolInfoInteger(symbol,SYMBOL_SWAP_MODE));
      case MODE_PROFITCALCMODE:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_CALC_MODE));
      case MODE_MARGINCALCMODE:
         return(0);
      case MODE_MARGININIT:
         return(0);
      case MODE_MARGINMAINTENANCE:
         return(0);
      case MODE_MARGINHEDGED:
         return(0);
      case MODE_MARGINREQUIRED:
         return(0);
      case MODE_FREEZELEVEL:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_FREEZE_LEVEL));

      default: return(0);
     }
   return(0);
  }
MarketInfo
Renvoie diverses données sur les titres répertoriés dans la fenêtre Market Watch.
SymbolInfoInteger, SymbolInfoDouble, Bid, Ask
int MessageBox(string text=NULL,
               string caption=NULL,
               int flags=EMPTY)
int MessageBox(string  text,
               string  caption=NULL,
               int     flags=0)
MessageBox
La fonction MessageBox crée, affiche et exploite la boîte de message.
MessageBox
void PlaySound(string filename)
bool PlaySound(string filename)
PlaySound
La fonction lit un fichier audio.
PlaySound
void Print(...)
void Print(argument,...)
Print
Imprime un message dans le journal des experts.
Print
bool SendFTP(string filename,
             string ftp_path=NULL)
bool SendFTP(string filename,
             string ftp_path=NULL)
SendFTP
Envoie le fichier au serveur FTP défini dans l'onglet Outils->Options->Éditeur. Si la tentative échoue, il renvoie FALSE.
SendFTP
void SendMail(string subject,
              string some_text)
bool SendMail(string  subject,
              string  some_text)
SendMail
Envoie un message à l'adresse e-mail définie dans l'onglet Outils->Options->Email.
SendMaill
void Sleep(int milliseconds)
void Sleep(int milliseconds)
Sleep
La fonction Sleep() suspend l'exécution de l'expert actuel dans l'intervalle indiqué.
Sleep


9. Fonctions de conversion

MQL4
MQL5
Description
string CharToStr(int char_code)
string CharToString(int char_code)
CharToStr
Conversion du code du symbole en une chaîne d'un caractère.
CharToString
string DoubleToStr(double value,
                   int digits)
string DoubleToString(double value,
                      int digits=8)
DoubleToStr
Renvoie une chaîne de texte avec la valeur numérique indiquée convertie dans un format de précision indiqué.
DoubleToString
double NormalizeDouble(double value,
                       int digits)
double NormalizeDouble(double value,
                       int digits)
NormalizeDouble
Arrondit la valeur à virgule flottante à la précision donnée. Renvoie la valeur normalisée du type double.
NormalizeDouble
double StrToDouble(string value)
double StringToDouble(string value)
StrToDouble
Convertit la représentation sous forme de chaîne de nombre en type double (format double précision avec virgule flottante).
StringToDouble
int StrToInteger(string value)
long StringToInteger(string value)
StrToInteger
Convertit la chaîne contenant la représentation du caractère de valeur en une valeur de type int (entier).
StringToInteger
datetime StrToTime(string value)
datetime StringToTime(string value)
StrToTime
Convertit la chaîne au format "aaaa.mm.jj hh:mi" en type datetime (le nombre de secondes écoulées depuis le 1er janvier 1970).
StringToTime
string TimeToStr(datetime value,
                 int mode=TIME_DATE|TIME_MINUTES)
string TimeToString(datetime value,
                    int mode=TIME_DATE|TIME_MINUTES)
TimeToStr
Convertit la valeur contenant le temps en secondes qui s'est écoulé depuis le 1er janvier 1970, en une chaîne au format "aaaa.mm.jj hh:mi".
TimeToString


10. Indicateurs personnalisés

MQL4
MQL5
 Description
void IndicatorBuffers(int count)
-IndicatorBuffers
Attribue de la mémoire pour les tampons utilisés pour les calculs d'indicateurs personnalisés.
int IndicatorCounted()
int IndicatorCountedMQL4()
  {
   if(prev_calculated>0) return(prev_calculated-1);
   if(prev_calculated==0) return(0);
   return(0);
  }
IndicatorCounted
La fonction renvoie le nombre de barres non modifiées après le dernier lancement de l'indicateur.
OnCalculate
void IndicatorDigits(int digits)
bool IndicatorSetInteger(INDICATOR_DIGITS,digits)
IndicatorDigits
Définit le format de précision (le nombre de chiffres après la virgule décimale) pour visualiser les valeurs des indicateurs.
IndicatorSetInteger
void IndicatorShortName(string name)
bool IndicatorSetString(INDICATOR_SHORTNAME,name)
IndicatorShortName
Définit le nom "court" d'un indicateur personnalisé à afficher dans la fenêtre de données et dans la sous-fenêtre du graphique.
IndicatorSetString
void SetIndexArrow(int index,
                   int code)
bool PlotIndexSetInteger(index,PLOT_ARROW,code)
SetIndexArrow
Définit un symbole de flèche pour la ligne d'indicateurs de type DRAW_ARROW.
PlotIndexSetInteger
bool SetIndexBuffer(int index,
                    double array[])
bool SetIndexBuffer(index,array,INDICATOR_DATA)
SetIndexBuffer
Lie la variable de tableau déclarée au niveau global au tampon prédéfini de l'indicateur personnalisé.
SetIndexBuffer
void SetIndexDrawBegin(int index,
                       int begin)
bool PlotIndexSetInteger(index,PLOT_DRAW_BEGIN,begin)
SetIndexDrawBegin
Définit le numéro de barre (à partir du début des données) à partir duquel le dessin de la ligne indicatrice donnée doit commencer.
PlotIndexSetInteger
void SetIndexEmptyValue(int index,
                        double value)
bool PlotIndexSetDouble(index,PLOT_EMPTY_VALUE,value)
SetIndexEmptyValue
définit la ligne de dessin à vide
PlotIndexSetDouble
void SetIndexLabel(int index,
                   string text)
bool PlotIndexSetString(index,PLOT_LABEL,text)
SetIndexLabel
Définit la description de la ligne de dessin à afficher dans la fenêtre de données et dans l'info-bulle.
PlotIndexSetString
void SetIndexShift(int index,
                   int shift)
bool PlotIndexSetInteger(index,PLOT_SHIFT,shift)
SetIndexShift
Définit le décalage de la ligne de dessin.
PlotIndexSetInteger
void SetIndexStyle(int index,
                   int type,
                   int style=EMPTY,
                   int width=EMPTY,
                   color clr=CLR_NONE)
void SetIndexStyleMQL4(int index,
                       int type,
                       int style=EMPTY,
                       int width=EMPTY,
                       color clr=CLR_NONE)
  {
   if(width>-1)
      PlotIndexSetInteger(index,PLOT_LINE_WIDTH,width);
   if(clr!=CLR_NONE)
      PlotIndexSetInteger(index,PLOT_LINE_COLOR,clr);
   switch(type)
     {
      case 0:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);
      case 1:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_SECTION);
      case 2:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);
      case 3:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ARROW);
      case 4:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
      case 12:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_NONE);

      default:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);
     }
   switch(style)
     {
      case 0:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_SOLID);
      case 1:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASH);
      case 2:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DOT);
      case 3:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOT);
      case 4:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOTDOT);

      default: return;
     }
SetIndexStyle
Définit le nouveau type, style, largeur et couleur pour une ligne d'indicateur donnée.
PlotIndexSetInteger
void SetLevelStyle(int draw_style,
                   int line_width,
                   color clr=CLR_NONE)
void SetLevelStyleMQL4(int draw_style,
                       int line_width,
                       color clr=CLR_NONE)
  {
   IndicatorSetInteger(INDICATOR_LEVELWIDTH,line_width);
   if(clr!=CLR_NONE)
      IndicatorSetInteger(INDICATOR_LEVELCOLOR,clr);
   switch(draw_style)
     {
      case 0:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_SOLID);
      case 1:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASH);
      case 2:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DOT);
      case 3:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOT);
      case 4:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOTDOT);

      default: return;
     }
  }
SetLevelStyle
La fonction définit un nouveau style, largeur et couleur des niveaux horizontaux de l'indicateur à afficher dans une fenêtre séparée.
IndicatorSetInteger
void SetLevelValue(int level,
                   double value)
bool IndicatorSetDouble(INDICATOR_LEVELVALUE,level,value)
SetLevelValue
La fonction définit une valeur pour un niveau horizontal donné de l'indicateur à afficher dans une fenêtre séparée.
IndicatorSetDouble


11. Fonctions de Date et d'Heure

MQL4
 MQL5Description
int Day()
int DayMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.day);
  }
Day
Renvoie le jour du mois courant, c'est-à-dire le jour du mois de la dernière heure connue du serveur.
TimeCurrent, MqlDateTime
int DayOfWeek()
int DayOfWeekMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.day_of_week);
  }
DayOfWeek
Renvoie le jour de la semaine actuel basé sur zéro (0-dimanche, 1, 2, 3, 4, 5, 6) de la dernière heure connue du serveur.
TimeCurrent, MqlDateTime
int DayOfYear()
int DayOfYearMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.day_of_year);
  }
DayOfYear
Renvoie le jour de l'année en cours (1 indique le 1er janvier,..., 365(6) correspond au 31 décembre), c'est-à-dire le jour de l'année de la dernière heure connue du serveur.
TimeCurrent, MqlDateTime
int Hour()
int HourMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.hour);
  }
Hour
Renvoie l'heure (0,1,2,..23) de la dernière heure connue du serveur au moment du démarrage du programme (cette valeur ne changera pas pendant l'exécution du programme).
TimeCurrent, MqlDateTime
int Minute()
int MinuteMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.min);
  }
Minute
Renvoie la minute actuelle (0,1,2,..59) de la dernière heure connue du serveur au moment du démarrage du programme (cette valeur ne changera pas pendant l'exécution du programme).
TimeCurrent, MqlDateTime
int Month()
int MonthMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.mon);
  }
Month
Renvoie le mois en cours sous forme de nombre (1-janvier,2,3,4,5,6,7,8,9,10,11,12), c'est-à-dire le nombre de mois de la dernière heure connue du serveur.
TimeCurrent, MqlDateTime
int Seconds()
int SecondsMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.sec);
  }
Seconds
Renvoie le nombre de secondes écoulées depuis le début de la minute actuelle de la dernière heure connue du serveur au moment du démarrage du programme (cette valeur ne changera pas pendant le temps d'exécution du programme).
TimeCurrent, MqlDateTime
datetime TimeCurrent()
datetime TimeCurrent()
TimeCurrent
Renvoie la dernière heure connue du serveur (heure d'arrivée de la dernière cotation) en nombre de secondes écoulées depuis 00:00 le 1er janvier 1970.
TimeCurrent
int TimeDay(datetime date)
int TimeDayMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.day);
  }
TimeDay
Renvoie le jour du mois (1 - 31) pour la date indiquée.
TimeToStruct, MqlDateTime
int TimeDayOfWeek(datetime date)
int TimeDayOfWeekMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.day_of_week);
  }
TimeDayOfWeek
Renvoie le jour de la semaine de base zéro (0 signifie dimanche, 1, 2, 3, 4, 5, 6) pour la date indiquée.
TimeToStruct, MqlDateTime
int TimeDayOfYear(datetime date)
int TimeDayOfYearMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.day_of_year);
  }
TimeDayOfYear
Renvoie le jour (1 indique le 1er janvier,..., 365(6) correspond au 31 décembre) de l'année pour la date indiquée
TimeToStruct, MqlDateTime
int TimeHour(datetime time)
int TimeHourMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.hour);
  }
TimeHour
Renvoie l'heure pour l'heure indiquée
TimeToStruct, MqlDateTime
datetime TimeLocal()
datetime TimeLocal()
TimeLocal
Renvoie l'heure de l'ordinateur local en nombre de secondes écoulées depuis 00:00 le 1er janvier 1970.
TimeLocal
int TimeMinute(datetime time)
int TimeMinuteMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.min);
  }
TimeMinute
Renvoie la minute pour l'heure indiquée.
TimeToStruct, MqlDateTime
int TimeMonth(datetime time)
int TimeMonthMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.mon);
  }
TimeMonth
Renvoie le numéro du mois pour l'heure spécifiée.
TimeToStruct, MqlDateTime
int TimeSeconds(datetime time)
int TimeSecondsMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.sec);
  }
TimeSeconds
Renvoie le nombre de secondes écoulées depuis le début de la minute pour la durée indiquée.
TimeToStruct, MqlDateTime
int TimeYear(datetime time)
int TimeYearMQL4(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.year);
  }
TimeYear
Renvoie l'année pour la date spécifiée. La valeur renvoyée peut être comprise entre 1970 et 2037.
TimeToStruct, MqlDateTime
int Year()
int YearMQL4()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.year);
  }
Year
Renvoie l'année en cours, c'est-à-dire l'année de la dernière heure connue du serveur.
TimeCurrent, MqlDateTime


12. Fonctions des Fichiers

MQL4
 MQL5 Description
void FileClose(int handle)
void FileClose(int file_handle)
FileClose
Ferme le fichier précédemment ouvert par la fonction FileOpen().
FileClose
void FileDelete(string filename)
bool FileDelete(string file_name
                int common_flag=0)
FileDelete
Supprime le nom de fichier indiqué.
FileDelete
void FileFlush(int handle)
void FileFlush(int file_handle)
FileFlush
Vide toutes les données stockées dans le tampon de fichier sur le disque.
FileFlush
bool FileIsEnding(int handle)
bool FileIsEnding(int file_handle)
FileIsEnding
Renvoie logique vraie si le pointeur de fichier est à la fin du fichier, sinon renvoie faux.
FileIsEnding
bool FileIsLineEnding(int handle)
bool FileIsLineEnding(int file_handle)
FileIsLineEnding
Pour CSV, le fichier renvoie la valeur logique vraie si le pointeur de fichier est à la fin de la ligne, sinon renvoie la valeur false.
FileIsLineEnding
int FileOpen(string filename,
             int mode,
             int delimiter=';')
int FileOpen(string ile_name,
             int pen_flags,
             short delimiter='\t'
             uint codepage=CP_ACP)
FileOpen
Ouvre le fichier pour l'entrée et/ou la sortie. Renvoie un descripteur de fichier pour le fichier ouvert ou -1 (si la fonction échoue).
FileOpen
int FileOpenHistory(string filename,
                    int mode,
                    int delimiter=';')
-FileOpenHistory
Ouvre le fichier dans le répertoire d'historique courant (répertoire_terminal\historique\nom_serveur) ou dans ses sous-dossiers. Renvoie le descripteur de fichier pour le fichier ouvert. Si la fonction échoue, la valeur renvoyée est -1.
int FileReadArray(int handle,
                  object &array[],
                  int start,
                  int count)
uint FileReadArray(int file_handle,
                   void array[],
                   int start_item=0,
                   int items_count=WHOLE_ARRAY)
FileReadArray
Lit la quantité indiquée d'éléments du fichier binaire dans un tableau.
FileReadArray
double FileReadDouble(int handle,
                      int size=DOUBLE_VALUE)
double FileReadDoubleMQL4(int handle,
                          int size=DOUBLE_VALUE)
  {
   return(FileReadDouble(handle));
  }
FileReadDouble
Lit le nombre double précision à virgule flottante à partir de la position actuelle du fichier binaire.
FileReadDouble
int FileReadInteger(int handle,
                    int size=LONG_VALUE)
int FileReadInteger(int file_handle,
                    int size=INT_VALUE)
FileReadInteger
La fonction lit l'entier à partir de la position actuelle du fichier binaire.
FileReadInteger
double FileReadNumber(int handle)
double FileReadNumber(int file_handle)
FileReadNumber
Lit le numéro à partir de la position actuelle du fichier avant le délimiteur. Uniquement pour les fichiers CSV.
FileReadNumber
string FileReadString(int handle,
                      int length=0)
string FileReadString(int file_handle,
                      int size=-1)
FileReadString
Функция читает строку с текущей позиции файла.
FileReadString
bool FileSeek(int handle,
              int offset,
              int origin)
bool FileSeekMQL4(long handle,
                  int offset,
                  ENUM_FILE_POSITION origin)
  {
   FileSeek(handle,offset,origin);
   return(true);
  }
FileSeek
La fonction déplace le pointeur de fichier vers une nouvelle position qui est un décalage, en octets, du début, de la fin ou de la position actuelle du fichier.
Recherche de fichier
int FileSize(int handle)
ulong FileSize(int file_handle)
FileSize
La fonction renvoie la taille du fichier en octets.
Taille du fichier
int FileTell(int handle)
ulong FileTell(int file_handle)
FileTell
Renvoie la position actuelle du pointeur de fichier.
FileTell
int FileWrite(int handle,...)
uint FileWrite(int file_handle,...)
FileWrite
La fonction est destinée à l'écriture de données dans un fichier CSV, le délimiteur étant inséré automatiquement.
FileWrite
int FileWriteArray(int handle,
                   object array[],
                   int start,
                   int count)
int FileWriteArray(int file_handle,
                   void array[],
                   int start_item=0,
                   int items_count=WHOLE_ARRAY)
FileWriteArray
La fonction écrit le tableau dans un fichier binaire.
FileWriteArray
int FileWriteDouble(int handle,
                    double value,
                    int size=DOUBLE_VALUE)
uint FileWriteDouble(int file_handle,
                     double dvalue)
FileWriteDouble
La fonction écrit une valeur double à virgule flottante dans un fichier binaire.
FileWriteDouble
int FileWriteInteger(int handle,
                     int value,
                     int size=LONG_VALUE)
uint FileWriteInteger(int file_handle,
                      int ivalue,
                      int size=INT_VALUE)
FileWriteInteger
La fonction écrit la valeur entière dans un fichier binaire.
FileWriteInteger
int FileWriteString(int handle,
                    string value,
                    int size)
uint FileWriteString(int file_handle,
                     string svalue,
                     int size=-1)
FileWriteString
La fonction écrit la chaîne dans un fichier binaire à partir de la position actuelle du fichier.
FileWriteString


13. Variables Globales

MQL4
MQL5
 Description
bool GlobalVariableCheck(string name)
bool GlobalVariableCheck(string name)
GlobalVariableCheck
Renvoie TRUE si la variable globale existe, sinon, renvoie FALSE.
GlobalVariableCheck
bool GlobalVariableDel(string name)
bool GlobalVariableDel(string name)
GlobalVariableDel
Supprime la variable globale.
GlobalVariableDel
double GlobalVariableGet(string name)
double GlobalVariableGet(string name)
GlobalVariableGet
Renvoie la valeur d'une variable globale existante ou 0 en cas d'erreur.
GlobalVariableGet
string GlobalVariableName(int index)
string GlobalVariableName(int index)
GlobalVariableName
La fonction renvoie le nom d'une variable globale par son index dans la liste des variables globales.
GlobalVariableName
datetime GlobalVariableSet(string name,
                           double value)
datetime GlobalVariableSet(string name,
                           double value)
GlobalVariableSet
Définit une nouvelle valeur de la variable globale. Si elle n'existe pas, le système crée une nouvelle variable globale.
GlobalVariableSet
bool GlobalVariableSetOnCondition(string name,
                                  double value,
                                  double check_value)
bool GlobalVariableSetOnCondition(string name,
                                  double value,
                                  double check_value)
GlobalVariableSetOnCondition
Définit la nouvelle valeur de la variable globale existante si la valeur actuelle est égale au troisième paramètre check_value.
GlobalVariableSetOnCondition
int GlobalVariablesDeleteAll(string prefix_name=NULL)
int GlobalVariablesDeleteAll(string prefix_name=NULL
                             datetime limit_data=0)
GlobalVariablesDeleteAll
Supprime les variables globales.
GlobalVariablesDeleteAll
int GlobalVariablesTotal()
int GlobalVariablesTotal()
GlobalVariablesTotal
La fonction renvoie le nombre total de variables globales.
GlobalVariablesTotal


14. Fonctions mathématiques

 MQL4MQL5
 Description
double MathAbs(double value)
double MathAbs(double value)
MathAbs
Renvoie la valeur absolue (module) de la valeur numérique indiquée.
MathAbs
double MathArccos(double x)
double MathArccos(double val)
MathArccos
La fonction MathArccos renvoie l'arc cosinus de x dans la plage 0 à Pi (en radians).
MathArccos
double MathArcsin(double x)
double MathArcsin(double val)
MathArcsin
La fonction MathArcsin renvoie l'arc sinus de x dans la plage -Pi/2 à Pi/2 radians.
MathArcsin
double MathArctan(double x)
double MathArctan(double value)
MathArctan
Le MathArctan renvoie l'arc tangente de x.
MathArctan
double MathCeil(double x)
double MathCeil(double val)
MathCeil
La fonction MathCeil renvoie une valeur numérique représentant le plus petit entier supérieur ou égal à x.
MathCeil
double MathCos(double value)
double MathCos(double value)
MathCos
Renvoie le cosinus de l'angle spécifié.
MathCos
double MathExp(double d)
double MathExp(double value)
MathExp
Renvoie la valeur de e élevée à la puissance d.
MathExp
double MathFloor(double x)
double MathFloor(double val)
MathFloor
La fonction MathFloor renvoie une valeur numérique représentant le plus grand entier inférieur ou égal à x.
MathFloor
double MathLog(double x)
double MathLog(double val)
MathLog
La fonction MathLog renvoie le logarithme népérien de x en cas de succès.
MathLog
double MathMax(double value1,
               double value2)
double MathMax(double value1,
               double value2)
MathMax
Renvoie la valeur maximale de deux valeurs numériques.
MathMax
double MathMin(double value1,
               double value2)
double MathMin(double value1,
               double value2)
MathMin
Renvoie la valeur minimale de deux valeurs numériques.
MathMin
double MathMod(double value1,
               double value2)
double MathMod(double value1,
               double value2)
MathMod
La fonction renvoie le reste de la virgule flottante de la division de deux nombres.
MathMod
double MathPow(double base,
               double exponent)
double MathPow(double base,
               double exponent)
MathPow
Renvoie la valeur de l'expression de base élevée à la puissance indiquée (valeur d'exposant).
MathPow
int MathRand()
int MathRand()
MathRand
La fonction MathRand renvoie un entier pseudo-aléatoire compris entre 0 et 32767.
MathRand
double MathRound(double value)
double MathRound(double value)
MathRound
Renvoie la valeur arrondie à l'entier le plus proche de la valeur numérique indiquée.
MathRound
double MathSin(double value)
double MathSin(double value)
MathSin
Renvoie le sinus de l'angle indiqué.
MathSin
double MathSqrt(double x)
double MathSqrt(double value)
MathSqrt
La fonction MathSqrt renvoie la racine carrée de x.
MathSqrt
void MathSrand(int seed)
void MathSrand(int seed)
MathSrand
La fonction MathSrand() définit le point de départ pour générer une série d'entiers pseudo-aléatoires.
MathSrand
double MathTan(double x)
double MathTan(double rad)
MathTan
MathTan renvoie la tangente de x.
MathTan


15. Fonctions d'Objet

MQL4
 MQL5Description
bool ObjectCreate(string name,
                  int type,
                  int window,
                  datetime time1,
                  double price1,
                  datetime time2=0,
                  double price2=0,
                  datetime time3=0,
                  double price3=0)
bool ObjectCreateMQL4(string name,
                      ENUM_OBJECT type,
                      int window,
                      datetime time1,
                      double price1,
                      datetime time2=0,
                      double price2=0,
                      datetime time3=0,
                      double price3=0)
  {
   return(ObjectCreate(0,name,type,window,
          time1,price1,time2,price2,time3,price3));
  }
ObjectCreate
Création d'un objet avec le nom, le type et les coordonnées initiales indiqués dans la fenêtre indiquée.
ObjectCreate
bool ObjectDelete(string name)
bool ObjectDeleteMQL4(string name)
  {
   return(ObjectDelete(0,name));
  }
ObjectDelete
Supprime l'objet disposant du nom indiqué.
ObjectDelete
string ObjectDescription(string name)
string ObjectDescriptionMQL4(string name)
  {
   return(ObjectGetString(0,name,OBJPROP_TEXT));
  }
ObjectDescription
Renvoie la description de l'objet.
ObjectGetString
int ObjectFind(string name)
int ObjectFindMQL4(string name)
  {
   return(ObjectFind(0,name));
  }
ObjectFind
Recherchez un objet disposant du nom indiqué.
ObjectFind
double ObjectGet(string name,
                 int prop_id)
double ObjectGetMQL4(string name,
                     int index)
  {
   switch(index)
     {
      case OBJPROP_TIME1:
         return(ObjectGetInteger(0,name,OBJPROP_TIME));
      case OBJPROP_PRICE1:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE));
      case OBJPROP_TIME2:
         return(ObjectGetInteger(0,name,OBJPROP_TIME,1));
      case OBJPROP_PRICE2:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE,1));
      case OBJPROP_TIME3:
         return(ObjectGetInteger(0,name,OBJPROP_TIME,2));
      case OBJPROP_PRICE3:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE,2));
      case OBJPROP_COLOR:
         return(ObjectGetInteger(0,name,OBJPROP_COLOR));
      case OBJPROP_STYLE:
         return(ObjectGetInteger(0,name,OBJPROP_STYLE));
      case OBJPROP_WIDTH:
         return(ObjectGetInteger(0,name,OBJPROP_WIDTH));
      case OBJPROP_BACK:
         return(ObjectGetInteger(0,name,OBJPROP_WIDTH));
      case OBJPROP_RAY:
         return(ObjectGetInteger(0,name,OBJPROP_RAY_RIGHT));
      case OBJPROP_ELLIPSE:
         return(ObjectGetInteger(0,name,OBJPROP_ELLIPSE));
      case OBJPROP_SCALE:
         return(ObjectGetDouble(0,name,OBJPROP_SCALE));
      case OBJPROP_ANGLE:
         return(ObjectGetDouble(0,name,OBJPROP_ANGLE));
      case OBJPROP_ARROWCODE:
         return(ObjectGetInteger(0,name,OBJPROP_ARROWCODE));
      case OBJPROP_TIMEFRAMES:
         return(ObjectGetInteger(0,name,OBJPROP_TIMEFRAMES));
      case OBJPROP_DEVIATION:
         return(ObjectGetDouble(0,name,OBJPROP_DEVIATION));
      case OBJPROP_FONTSIZE:
         return(ObjectGetInteger(0,name,OBJPROP_FONTSIZE));
      case OBJPROP_CORNER:
         return(ObjectGetInteger(0,name,OBJPROP_CORNER));
      case OBJPROP_XDISTANCE:
         return(ObjectGetInteger(0,name,OBJPROP_XDISTANCE));
      case OBJPROP_YDISTANCE:
         return(ObjectGetInteger(0,name,OBJPROP_YDISTANCE));
      case OBJPROP_FIBOLEVELS:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELS));
      case OBJPROP_LEVELCOLOR:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELCOLOR));
      case OBJPROP_LEVELSTYLE:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELSTYLE));
      case OBJPROP_LEVELWIDTH:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELWIDTH));
     }
  }
ObjectGet
La fonction renvoie la valeur de la propriété d'objet indiquée.
ObjectGetInteger, ObjectGetDouble

string ObjectGetFiboDescription(string name,
                                int index)
string ObjectGetFiboDescriptionMQL4(string name,
                                    int index)
  {
   return(ObjectGetString(0,name,OBJPROP_LEVELTEXT,index));
  }
ObjectGetFiboDescription
La fonction renvoie la description de niveau d'un objet de Fibonacci.
ObjectGetString
int ObjectGetShiftByValue(string name,
                          double value)
int ObjectGetShiftByValueMQL4(string name,
                              double value)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   datetime Arr[];
   int shift;
   MqlRates mql4[];
   if(ObjectGetTimeByValue(0,name,value)<0) return(-1);
   CopyRates(NULL,timeframe,0,1,mql4);
   if(CopyTime(NULL,timeframe,mql4[0].time,
      ObjectGetTimeByValue(0,name,value),Arr)>0)
      return(ArraySize(Arr)-1);
   else return(-1);
  }
ObjectGetShiftByValue
La fonction calcule et renvoie l'indice de barre (décalage lié à la barre actuelle) pour le prix donné.
MqlRates, ObjectGetTimeByValue, CopyRates, CopyTime, ArraySize
double ObjectGetValueByShift(string name,
                             int shift)
double ObjectGetValueByShiftMQL4(string name,
                                 int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   MqlRates mql4[];
   CopyRates(NULL,timeframe,shift,1,mql4);
   return(ObjectGetValueByTime(0,name,mql4[0].time,0));
  }
ObjectGetValueByShift
La fonction calcule et renvoie la valeur du prix de la barre indiquée (décalage lié à la barre actuelle).
MqlRates, CopyRates, ObjectGetValueByTime
bool ObjectMove(string name,
                int point,
                datetime time1,
                double price1)
bool ObjectMoveMQL4(string name,
                    int point,
                    datetime time1,
                    double price1)
  {
   return(ObjectMove(0,name,point,time1,price1));
  }
ObjectMove
La fonction déplace une coordonnée d'objet dans le graphique. Les objets peuvent disposer d’une à trois coordonnées en fonction de leurs types
ObjectMove
string ObjectName(int index)
string ObjectNameMQL4(int index)
  {
   return(ObjectName(0,index));
  }
ObjectName
La fonction renvoie le nom de l'objet par son index dans la liste des objets.
ObjectName
int ObjectsDeleteAll(int window=EMPTY,
                     int type=EMPTY)
int ObjectsDeleteAllMQL4(int window=EMPTY,
                         int type=EMPTY)
  {
   return(ObjectsDeleteAll(0,window,type));
  }
ObjectsDeleteAll
Supprime tous les objets du type indiqué et dans la sous-fenêtre spécifiée du graphique.
ObjectsDeleteAll
bool ObjectSet(string name,
               int prop_id,
               double value)
bool ObjectSetMQL4(string name,
                   int index,
                   double value)
  {
   switch(index)
     {
      case OBJPROP_TIME1:
         ObjectSetInteger(0,name,OBJPROP_TIME,(int)value);return(true);
      case OBJPROP_PRICE1:
         ObjectSetDouble(0,name,OBJPROP_PRICE,value);return(true);
      case OBJPROP_TIME2:
         ObjectSetInteger(0,name,OBJPROP_TIME,1,(int)value);return(true);
      case OBJPROP_PRICE2:
         ObjectSetDouble(0,name,OBJPROP_PRICE,1,value);return(true);
      case OBJPROP_TIME3:
         ObjectSetInteger(0,name,OBJPROP_TIME,2,(int)value);return(true);
      case OBJPROP_PRICE3:
         ObjectSetDouble(0,name,OBJPROP_PRICE,2,value);return(true);
      case OBJPROP_COLOR:
         ObjectSetInteger(0,name,OBJPROP_COLOR,(int)value);return(true);
      case OBJPROP_STYLE:
         ObjectSetInteger(0,name,OBJPROP_STYLE,(int)value);return(true);
      case OBJPROP_WIDTH:
         ObjectSetInteger(0,name,OBJPROP_WIDTH,(int)value);return(true);
      case OBJPROP_BACK:
         ObjectSetInteger(0,name,OBJPROP_BACK,(int)value);return(true);
      case OBJPROP_RAY:
         ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,(int)value);return(true);
      case OBJPROP_ELLIPSE:
         ObjectSetInteger(0,name,OBJPROP_ELLIPSE,(int)value);return(true);
      case OBJPROP_SCALE:
         ObjectSetDouble(0,name,OBJPROP_SCALE,value);return(true);
      case OBJPROP_ANGLE:
         ObjectSetDouble(0,name,OBJPROP_ANGLE,value);return(true);
      case OBJPROP_ARROWCODE:
         ObjectSetInteger(0,name,OBJPROP_ARROWCODE,(int)value);return(true);
      case OBJPROP_TIMEFRAMES:
         ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,(int)value);return(true);
      case OBJPROP_DEVIATION:
         ObjectSetDouble(0,name,OBJPROP_DEVIATION,value);return(true);
      case OBJPROP_FONTSIZE:
         ObjectSetInteger(0,name,OBJPROP_FONTSIZE,(int)value);return(true);
      case OBJPROP_CORNER:
         ObjectSetInteger(0,name,OBJPROP_CORNER,(int)value);return(true);
      case OBJPROP_XDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,(int)value);return(true);
      case OBJPROP_YDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,(int)value);return(true);
      case OBJPROP_FIBOLEVELS:
         ObjectSetInteger(0,name,OBJPROP_LEVELS,(int)value);return(true);
      case OBJPROP_LEVELCOLOR:
         ObjectSetInteger(0,name,OBJPROP_LEVELCOLOR,(int)value);return(true);
      case OBJPROP_LEVELSTYLE:
         ObjectSetInteger(0,name,OBJPROP_LEVELSTYLE,(int)value);return(true);
      case OBJPROP_LEVELWIDTH:
         ObjectSetInteger(0,name,OBJPROP_LEVELWIDTH,(int)value);return(true);

      default: return(false);
     }
   return(false);
  }
ObjectSet
Modifie la valeur de la propriété d'objet indiquée.
ObjectSetInteger, ObjectSetDouble
bool ObjectSetFiboDescription(string name,
                              int index,
                              string text)
bool ObjectSetFiboDescriptionMQL4(string name,
                                  int index,
                                  string text)
  {
   return(ObjectSetString(0,name,OBJPROP_LEVELTEXT,index,text));
  }
ObjectSetFiboDescription
La fonction attribue une nouvelle description à un niveau d'un objet de Fibonacci.
ObjectSetString
bool ObjectSetText(string name,
                   string text,
                   int font_size,
                   string font_name=NULL,
                   color text_color=CLR_NONE)
bool ObjectSetTextMQL4(string name,
                       string text,
                       int font_size,
                       string font="",
                       color text_color=CLR_NONE)
  {
   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);
   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);
   if(StringLen(text)>0 && font_size>0)
     {
      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true
         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)
        {
         if((StringLen(font)>0)
            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)
            return(false);
         if(text_color>-1
            && ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)
            return(false);
         return(true);
        }
      return(false);
     }
   return(false);
  }
ObjectSetText
Modifie la description de l'objet.
ObjectGetInteger, ObjectSetString, ObjectSetInteger StringLen
int ObjectsTotal(int type=EMPTY)
int ObjectsTotalMQL4(int type=EMPTY,
                     int window=-1)
  {
   return(ObjectsTotal(0,window,type));
  }
ObjectsTotal
Renvoie le nombre total d'objets du type indiqué dans le graphique.
ObjectsTotal
int ObjectType(string name)
int ObjectTypeMQL4(string name)
  {
   return((int)ObjectGetInteger(0,name,OBJPROP_TYPE));
  }
ObjectType
La fonction renvoie la valeur du type d'objet.
ObjectGetInteger


16. Fonctions de Chaîne

MQL4
MQL5
 Description
string StringConcatenate(...)
int StringConcatenate(string &string_var,
                      void argument1
                      void argument2
                      ...)
StringConcatenate
Forme une chaîne des données transmises et la renvoie.
StringConcatenate
int StringFind(string text,
               string matched_text,
               int start=0)
int StringFind(string string_value,
               string match_substring,
               int start_pos=0)
StringFind
Recherchez une sous-chaîne. Renvoie la position dans la chaîne à partir de laquelle commence la sous-chaîne recherchée, ou -1 si la sous-chaîne n'a pas été trouvée.
ChaîneRechercher
int StringGetChar(string text,
                  int pos)
ushort StringGetCharacter(string string_value,
                          int pos)
StringGetChar
Renvoie le caractère (code) à partir de la position indiquée dans la chaîne.
StringGetCharacter
int StringLen(string text)
int StringLen(string string_value)
StringLen
Renvoie le nombre de caractères dans une chaîne.
StringLen
string StringSetChar(string text,
                     int pos,
                     int value)
bool StringSetCharacter(string &string_var,
                        int pos,
                        ushort character)
StringSetChar
Renvoie la copie de la chaîne avec le caractère modifié dans la position indiquée.
StringSetCharacter
string StringSubstr(string text,
                    int start,
                    int length=0)
string StringSubstr(string string_value,
                    int start_pos,
                    int length=-1)
StringSubstr
Extrait une sous-chaîne d'une chaîne de texte à partir de la position donnée.
StringSubstr
string StringTrimLeft(string text)
int StringTrimLeft(string& string_var)
StringTrimLeft
La fonction coupe les caractères interligne, les espaces et les tabulations dans la partie gauche de la chaîne.
StringTrimLeft
string StringTrimRight(string text)
int StringTrimRight(string& string_var)
StringTrimRight
La fonction coupe les caractères interligne, les espaces et les tabulations dans la partie droite de la chaîne.
StringTrimRight


17. Indicateurs Techniques

Les principes d'utilisation des indicateurs techniques dans les Expert Advisors sont abordés dans l'article MQL5 pour débutants : Guide d'utilisation des indicateurs techniques dans les Expert Advisors. La méthode utilisée dans cette référence est suffisante pour obtenir les résultats du calcul de l'indicateur pour le prix indiqué. Pour utiliser cette méthode, nous avons besoin de la fonction auxiliaire :

double CopyBufferMQL4(int handle,int index,int shift)
  {
   double buf[];
   switch(index)
     {
      case 0: if(CopyBuffer(handle,0,shift,1,buf)>0)
         return(buf[0]); break;
      case 1: if(CopyBuffer(handle,1,shift,1,buf)>0)
         return(buf[0]); break;
      case 2: if(CopyBuffer(handle,2,shift,1,buf)>0)
         return(buf[0]); break;
      case 3: if(CopyBuffer(handle,3,shift,1,buf)>0)
         return(buf[0]); break;
      case 4: if(CopyBuffer(handle,4,shift,1,buf)>0)
         return(buf[0]); break;
      default: break;
     }
   return(EMPTY_VALUE);
  }
déclarons les constantes suivantes :
ENUM_MA_METHOD MethodMigrate(int method)
  {
   switch(method)
     {
      case 0: return(MODE_SMA);
      case 1: return(MODE_EMA);
      case 2: return(MODE_SMMA);
      case 3: return(MODE_LWMA);
      default: return(MODE_SMA);
     }
  }
ENUM_APPLIED_PRICE PriceMigrate(int price)
  {
   switch(price)
     {
      case 1: return(PRICE_CLOSE);
      case 2: return(PRICE_OPEN);
      case 3: return(PRICE_HIGH);
      case 4: return(PRICE_LOW);
      case 5: return(PRICE_MEDIAN);
      case 6: return(PRICE_TYPICAL);
      case 7: return(PRICE_WEIGHTED);
      default: return(PRICE_CLOSE);
     }
  }
ENUM_STO_PRICE StoFieldMigrate(int field)
  {
   switch(field)
     {
      case 0: return(STO_LOWHIGH);
      case 1: return(STO_CLOSECLOSE);
      default: return(STO_LOWHIGH);
     }
  }
//+------------------------------------------------------------------+
enum ALLIGATOR_MODE  { MODE_GATORJAW=1,   MODE_GATORTEETH, MODE_GATORLIPS };
enum ADX_MODE        { MODE_MAIN,         MODE_PLUSDI, MODE_MINUSDI };
enum UP_LOW_MODE     { MODE_BASE,         MODE_UPPER,      MODE_LOWER };
enum ICHIMOKU_MODE   { MODE_TENKANSEN=1,  MODE_KIJUNSEN, MODE_SENKOUSPANA, MODE_SENKOUSPANB, MODE_CHINKOUSPAN };
enum MAIN_SIGNAL_MODE{ MODE_MAIN,         MODE_SIGNAL };
MQL4
 MQL5 Decsription
double iAC(string symbol,
           int timeframe,
           int shift)
double iACMQL4(string symbol,
               int tf,
               int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iAC(symbol,timeframe);
   if(handle<0)
     {
      Print("The iAC object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iAC
Calcule l'oscillateur Accélérateur/Décélérateur de Bill Williams.
iAC
double iAD(string symbol,
           int timeframe,
           int shift)
double iADMQL4(string symbol,
               int tf,
               int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=(int)iAD(symbol,timeframe,VOLUME_TICK);
   if(handle<0)
     {
      Print("The iAD object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iAD
Calcule l'indicateur Accumulation/Distribution et retourne sa valeur.
iAD
double iAlligator(string symbol,
                  int timeframe,
                  int jaw_period,
                  int jaw_shift,
                  int teeth_period,
                  int teeth_shift,
                  int lips_period,
                  int lips_shift,
                  int ma_method,
                  int applied_price,
                  int mode,
                  int shift)
double iAlligatorMQL4(string symbol,
                      int tf,
                      int jaw_period,
                      int jaw_shift,
                      int teeth_period,
                      int teeth_shift,
                      int lips_period,
                      int lips_shift,
                      int method,
                      int price,
                      int mode,
                      int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iAlligator(symbol,timeframe,jaw_period,jaw_shift,
                         teeth_period,teeth_shift,
                         lips_period,lips_shift,
                         ma_method,applied_price);
   if(handle<0)
     {
      Print("The iAlligator object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }
iAlligator
Calcule l'alligator de Bill Williams et renvoie sa valeur.
iAlligator
double iADX(string symbol,
            int timeframe,
            int period,
            int applied_price,
            int mode,
            int shift)
double iADXMQL4(string symbol,
                int tf,
                int period,
                int price,
                int mode,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iADX(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iADX object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode,shift));
  }
iADX
Calcule l'Indice Directionnel du Mouvement et renvoie sa valeur.
iADX
double iATR(string symbol,
            int timeframe,
            int period,
            int shift)
double iATRMQL4(string symbol,
                int tf,
                int period,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iATR(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iATR object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iATR
Calcule l'indicateur d’étendue moyenne réelle et renvoie sa valeur.
iATR
double iAO(string symbol,
           int timeframe,
           int shift)
double iAOMQL4(string symbol,
               int tf,
               int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iAO(symbol,timeframe);
   if(handle<0)
     {
      Print("The iAO object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iAO
Calcule l'oscillateur Awesome de Bill Williams et renvoie sa valeur.
iAO
double iBearsPower(string symbol,
                   int timeframe,
                   int period,
                   int applied_price,
                   int shift)
double iBearsPowerMQL4(string symbol,
                       int tf,
                       int period,
                       int price,
                       int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iBearsPower(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iBearsPower object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iBearsPower
Calcule l'indicateur Bears Power et renvoie sa valeur.
iBearsPower
double iBands(string symbol,
              int timeframe,
              int period,
              int deviation,
              int bands_shift,
              int applied_price,
              int mode,
              int shift)
double iBandsMQL4(string symbol,
                  int tf,
                  int period,
                  double deviation,
                  int bands_shift,
                  int method,
                  int mode,
                  int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   int handle=iBands(symbol,timeframe,period,
                     bands_shift,deviation,ma_method);
   if(handle<0)
     {
      Print("The iBands object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode,shift));
  }
iBands
Calcule l'indicateur des bandes de Bollinger et renvoie sa valeur.
iBands
double iBandsOnArray(double array[],
                     int total,
                     int period,
                     int deviation,
                     int bands_shift,
                     int mode,
                     int shift)
-iBandsOnArray
Calcul de l'indicateur des bandes de Bollinger sur des données stockées dans un tableau numérique.
double iBullsPower(string symbol,
                   int timeframe,
                   int period,
                   int applied_price,
                   int shift)
double iBullsPowerMQL4(string symbol,
                       int tf,
                       int period,
                       int price,
                       int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iBullsPower(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iBullsPower object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iBullsPower
Calcule l'indicateur Bulls Power et renvoie sa valeur.
iBullsPower
double iCCI(string symbol,
            int timeframe,
            int period,
            int applied_price,
            int shift)
double iCCIMQL4(string symbol,
                int tf,
                int period,
                int price,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iCCI(symbol,timeframe,period,price);
   if(handle<0)
     {
      Print("The iCCI object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iCCI
Calcule l'index du Commodity Channel et renvoie sa valeur.
iCCI
double iCCIOnArray(double array[],
                   int total,
                   int period,
                   int shift)
-iCCIOnArray
Calcul du Commodity Channel Index sur les données stockées dans un tableau numérique.
double iCustom(string symbol,
               int timeframe,
               string name,
               ...,
               int mode,
               int shift)
int iCustom(string symbol,
            ENUM_TIMEFRAMES period,
            string name
            ...)
iCustom
Calcule l'indicateur personnalisé indiqué et renvoie sa valeur.
iCustom
double iDeMarker(string symbol,
                 int timeframe,
                 int period,
                 int shift)
double iDeMarkerMQL4(string symbol,
                     int tf,
                     int period,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iDeMarker(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iDeMarker object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iDeMarker
Calcule l'indicateur DeMarker et renvoie sa valeur.
iDeMarker
double iEnvelopes(string symbol,
                  int timeframe,
                  int ma_period,
                  int ma_method,
                  int ma_shift,
                  int applied_price,
                  double deviation,
                  int mode,
                  int shift)
double EnvelopesMQL4(string symbol,
                     int tf,
                     int ma_period,
                     int method,
                     int ma_shift,
                     int price,
                     double deviation,
                     int mode,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iEnvelopes(symbol,timeframe,
                         ma_period,ma_shift,ma_method,
                         applied_price,deviation);
   if(handle<0)
     {
      Print("The iEnvelopes object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }
iEnvelopes
Calcule l'indicateur Enveloppes et renvoie sa valeur.
iEnvelopes
double iEnvelopesOnArray(double array[],
                         int total,
                         int ma_period,
                         int ma_method,
                         int ma_shift,
                         double deviation,
                         int mode,
                         int shift)
-iEnvelopesOnArray
Calcul de l'indicateur Enveloppes sur des données stockées dans un tableau numérique.
double iForce(string symbol,
              int timeframe,
              int period,
              int ma_method,
              int applied_price,
              int shift)
double iForceMQL4(string symbol,
                  int tf,
                  int period,
                  int method,
                  int price,
                  int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   int handle=iForce(symbol,timeframe,period,ma_method,VOLUME_TICK);
   if(handle<0)
     {
      Print("The iForce object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iForce
Calcule l'index de force et renvoie sa valeur.
iForce
double iFractals(string symbol,
                 int timeframe,
                 int mode,
                 int shift)
double iFractalsMQL4(string symbol,
                     int tf,
                     int mode,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iFractals(symbol,timeframe);
   if(handle<0)
     {
      Print("The iFractals object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }
iFractals
Calcule les Fractales et renvoie sa valeur.
iFractals
double iGator(string symbol,
              int timeframe,
              int jaw_period,
              int jaw_shift,
              int teeth_period,
              int teeth_shift,
              int lips_period,
              int lips_shift,
              int ma_method,
              int applied_price,
              int mode,
              int shift)
double iGatorMQL4(string symbol,
                  int tf,
                  int jaw_period,
                  int jaw_shift,
                  int teeth_period,
                  int teeth_shift,
                  int lips_period,
                  int lips_shift,
                  int method,
                  int price,
                  int mode,
                  int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iGator(symbol,timeframe,jaw_period,jaw_shift,
                     teeth_period,teeth_shift,
                     lips_period,lips_shift,
                     ma_method,applied_price);
   if(handle<0)
     {
      Print("The iGator object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }
iGator
Calcul de l'oscillateur Gator.
iGator
double iIchimoku(string symbol,
                 int timeframe,
                 int tenkan_sen,
                 int kijun_sen,
                 int senkou_span_b,
                 int mode,
                 int shift)
double iIchimokuMQL4(string symbol,
                     int tf,
                     int tenkan_sen,
                     int kijun_sen,
                     int senkou_span_b,
                     int mode,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iIchimoku(symbol,timeframe,
                        tenkan_sen,kijun_sen,senkou_span_b);
   if(handle<0)
     {
      Print("The iIchimoku object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }
iIchimoku
Calcule l'Ichimoku Kinko Hyo et renvoie sa valeur.
iIchimoku
double iBWMFI(string symbol,
              int timeframe,
              int shift)
double iBWMFIMQL4(string symbol,
                  int tf,
                  int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=(int)iBWMFI(symbol,timeframe,VOLUME_TICK);
   if(handle<0)
     {
      Print("The iBWMFI object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iBWMFI
Calcule l'indice de facilitation du marché Bill Williams et renvoie sa valeur.
iBWMFI
double iMomentum(string symbol,
                 int timeframe,
                 int period,
                 int applied_price,
                 int shift)
double iMomentumMQL4(string symbol,
                     int tf,
                     int period,
                     int price,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iMomentum(symbol,timeframe,period,applied_price);
   if(handle<0)
     {
      Print("The iMomentum object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iMomentum
Calcule l'indicateur Momentum et renvoie sa valeur.
iMomentum
double iMomentumOnArray(double array[],
                        int total,
                        int period,
                        int shift)
-iMomentumOnArray
Calcul de l'indicateur Momentum sur des données stockées dans un tableau numérique.
double iMFI(string symbol,
            int timeframe,
            int period,
            int shift)
double iMFIMQL4(string symbol,
                int tf,
                int period,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=(int)iMFI(symbol,timeframe,period,VOLUME_TICK);
   if(handle<0)
     {
      Print("The iMFI object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iMFI
Calcule l'indice de flux Monétaire et renvoie sa valeur.
iMFI
double iMA(string symbol,
           int timeframe,
           int period,
           int ma_shift,
           int ma_method,
           int applied_price,
           int shift)
double iMAMQL4(string symbol,
               int tf,
               int period,
               int ma_shift,
               int method,
               int price,
               int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iMA(symbol,timeframe,period,ma_shift,
                  ma_method,applied_price);
   if(handle<0)
     {
      Print("The iMA object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iMA
Calcule l'indicateur de moyenne Mobile et renvoie sa valeur.
iMA
double iMAOnArray(double array[],
                  int total,
                  int period,
                  int ma_shift,
                  int ma_method,
                  int shift)
double iMAOnArrayMQL4(double &array[],
                      int total,
                      int period,
                      int ma_shift,
                      int ma_method,
                      int shift)
  {
   double buf[],arr[];
   if(total==0) total=ArraySize(array);
   if(total>0 && total<=period) return(0);
   if(shift>total-period-ma_shift) return(0);
   switch(ma_method)
     {
      case MODE_SMA :
        {
         total=ArrayCopy(arr,array,0,shift+ma_shift,period);
         if(ArrayResize(buf,total)<0) return(0);
         double sum=0;
         int    i,pos=total-1;
         for(i=1;i<period;i++,pos--)
            sum+=arr[pos];
         while(pos>=0)
           {
            sum+=arr[pos];
            buf[pos]=sum/period;
            sum-=arr[pos+period-1];
            pos--;
           }
         return(buf[0]);
        }
      case MODE_EMA :
        {
         if(ArrayResize(buf,total)<0) return(0);
         double pr=2.0/(period+1);
         int    pos=total-2;
         while(pos>=0)
           {
            if(pos==total-2) buf[pos+1]=array[pos+1];
            buf[pos]=array[pos]*pr+buf[pos+1]*(1-pr);
            pos--;
           }
         return(buf[shift+ma_shift]);
        }
      case MODE_SMMA :
        {
         if(ArrayResize(buf,total)<0) return(0);
         double sum=0;
         int    i,k,pos;
         pos=total-period;
         while(pos>=0)
           {
            if(pos==total-period)
              {
               for(i=0,k=pos;i<period;i++,k++)
                 {
                  sum+=array[k];
                  buf[k]=0;
                 }
              }
            else sum=buf[pos+1]*(period-1)+array[pos];
            buf[pos]=sum/period;
            pos--;
           }
         return(buf[shift+ma_shift]);
        }
      case MODE_LWMA :
        {
         if(ArrayResize(buf,total)<0) return(0);
         double sum=0.0,lsum=0.0;
         double price;
         int    i,weight=0,pos=total-1;
         for(i=1;i<=period;i++,pos--)
           {
            price=array[pos];
            sum+=price*i;
            lsum+=price;
            weight+=i;
           }
         pos++;
         i=pos+period;
         while(pos>=0)
           {
            buf[pos]=sum/weight;
            if(pos==0) break;
            pos--;
            i--;
            price=array[pos];
            sum=sum-lsum+price*period;
            lsum-=array[i];
            lsum+=price;
           }
         return(buf[shift+ma_shift]);
        }
      default: return(0);
     }
   return(0);
  }

double iOsMA(string symbol,
             int timeframe,
             int fast_ema_period,
             int slow_ema_period,
             int signal_period,
             int applied_price,
             int shift)
double iOsMAMQL4(string symbol,
                 int tf,
                 int fast_ema_period,
                 int slow_ema_period,
                 int signal_period,
                 int price,
                 int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iOsMA(symbol,timeframe,
                    fast_ema_period,slow_ema_period,
                    signal_period,applied_price);
   if(handle<0)
     {
      Print("The iOsMA object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iOsMA
Calcule la moyenne Mobile de l'oscillateur et renvoie sa valeur.
iOsMA
double iMACD(string symbol,
             int timeframe,
             int fast_ema_period,
             int slow_ema_period,
             int signal_period,
             int applied_price,
             int mode,
             int shift)
double iMACDMQL4(string symbol,
                 int tf,
                 int fast_ema_period,
                 int slow_ema_period,
                 int signal_period,
                 int price,
                 int mode,
                 int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iMACD(symbol,timeframe,
                    fast_ema_period,slow_ema_period,
                    signal_period,applied_price);
   if(handle<0)
     {
      Print("The iMACD object is not created: Error ",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode,shift));
  }
iMACD
Calcule la convergence/divergence des moyennes Mobiles et renvoie sa valeur.
iMACD
double iOBV(string symbol,
            int timeframe,
            int applied_price,
            int shift)
double iOBVMQL4(string symbol,
                int tf,
                int price,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iOBV(symbol,timeframe,VOLUME_TICK);
   if(handle<0)
     {
      Print("The iOBV object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iOBV
Calcule l'indicateur du graphique du Volume et renvoie sa valeur.
iOBV
double iSAR(string symbol,
            int timeframe,
            double step,
            double maximum,
            int shift)
double iSARMQL4(string symbol,
                int tf,
                double step,
                double maximum,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iSAR(symbol,timeframe,step,maximum);
   if(handle<0)
     {
      Print("The iSAR object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iSAR
Calcule le système Parabolic Stop and Reverse et renvoie sa valeur.
iSAR
double iRSI(string symbol,
            int timeframe,
            int period,
            int applied_price,
            int shift)
double iRSIMQL4(string symbol,
                int tf,
                int period,
                int price,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iRSI(symbol,timeframe,period,applied_price);
   if(handle<0)
     {
      Print("The iRSI object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iRSI
Calcule l'indice de force Relative et renvoie sa valeur.
iRSI
double iRSIOnArray(double array[],
                   int total,
                   int period,
                   int shift)
-iRSIOnArray
Calcul de l'indice de force Relative sur des données stockées dans un tableau numérique.
double iRVI(string symbol,
            int timeframe,
            int period,
            int mode,
            int shift)
double iRVIMQL4(string symbol,
                int tf,
                int period,
                int mode,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iRVI(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iRVI object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode,shift));
  }
iRVI
Calcule l'indice de vigueur Relative et renvoie sa valeur.
iRVI
double iStdDev(string symbol,
               int timeframe,
               int ma_period,
               int ma_shift,
               int ma_method,
               int applied_price,
               int shift)
double iStdDevMQL4(string symbol,
                   int tf,
                   int ma_period,
                   int ma_shift,
                   int method,
                   int price,
                   int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iStdDev(symbol,timeframe,ma_period,ma_shift,
                      ma_method,applied_price);
   if(handle<0)
     {
      Print("The iStdDev object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iStdDev
Calcule l'indicateur d' Ecart Type et renvoie sa valeur.
iStdDev
double iStdDevOnArray(double array[],
                      int total,
                      int ma_period,
                      int ma_shift,
                      int ma_method,
                      int shift)
-iStdDevOnArray
Calcul de l'indicateur d'Ecart Type sur les données stockées dans un tableau numérique.
double iStochastic(string symbol,
                   int timeframe,
                   int%Kperiod,
                   int%Dperiod,
                   int slowing,
                   int method,
                   int price_field,
                   int mode,
                   int shift)
double iStochasticMQL4(string symbol,
                       int tf,
                       int Kperiod,
                       int Dperiod,
                       int slowing,
                       int method,
                       int field,
                       int mode,
                       int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_STO_PRICE price_field=StoFieldMigrate(field);
   int handle=iStochastic(symbol,timeframe,Kperiod,Dperiod,
                          slowing,ma_method,price_field);
   if(handle<0)
     {
      Print("The iStochastic object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode,shift));
  }
iStochastic
Calcule l'oscillateur Stochastique et renvoie sa valeur.
iStochastic
double iWPR(string symbol,
            int timeframe,
            int period,
            int shift)
double iWPRMQL4(string symbol,
                int tf,
                int period,
                int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iWPR(symbol,timeframe,period);
   if(handle<0)
     {
      Print("The iWPR object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }
iWPR
Calcule l'indicateur de plage de pourcentage de Larry William et renvoie sa valeur.
iWPR


18. Accès aux séries temporelles

MQL4
 MQL5 Description
int iBars(string symbol,
          int timeframe)
int iBarsMQL4(string symbol,int tf)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   return(Bars(symbol,timeframe));
  }
int iBarsMQL4(string symbol,int tf)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   return(Bars(symbol,timeframe));
  }
Bars

Renvoie le nombre de barres sur le graphique indiqué.
Barres
int iBarShift(string symbol,
              int timeframe,
              datetime time,
              bool exact=false
int iBarShiftMQL4(string symbol,
                  int tf,
                  datetime time,
                  bool exact=false)
  {
   if(time<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[],time1;
   CopyTime(symbol,timeframe,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
  }
iBarShift
Rechercher une barre par heure d'ouverture.
CopyTime, ArraySize
double iClose(string symbol,
              int timeframe,
              int shift)
double iCloseMQL4(string symbol,int tf,int index)
{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyClose(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}
Close
Renvoie la valeur de clôture pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates
double iHigh(string symbol,
             int timeframe,
             int shift)
double iHighMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyHigh(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}
High
Renvoie la valeur haute pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates
int iHighest(string symbol,
             int timeframe,
             int type,
             int count=WHOLE_ARRAY,
             int start=0)
int iHighestMQL4(string symbol,
                 int tf,
                 int type,
                 int count=WHOLE_ARRAY,
                 int start=0)
  {
   if(start<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(count<=0) count=Bars(symbol,timeframe);
   if(type<=MODE_OPEN)
     {
      double Open[];
      ArraySetAsSeries(Open,true);
      CopyOpen(symbol,timeframe,start,count,Open);
      return(ArrayMaximum(Open,0,count)+start);
     }
   if(type==MODE_LOW)
     {
      double Low[];
      ArraySetAsSeries(Low,true);
      CopyLow(symbol,timeframe,start,count,Low);
      return(ArrayMaximum(Low,0,count)+start);
     }
   if(type==MODE_HIGH)
     {
      double High[];
      ArraySetAsSeries(High,true);
      CopyHigh(symbol,timeframe,start,count,High);
      return(ArrayMaximum(High,0,count)+start);
     }
   if(type==MODE_CLOSE)
     {
      double Close[];
      ArraySetAsSeries(Close,true);
      CopyClose(symbol,timeframe,start,count,Close);
      return(ArrayMaximum(Close,0,count)+start);
     }
   if(type==MODE_VOLUME)
     {
      long Volume[];
      ArraySetAsSeries(Volume,true);
      CopyTickVolume(symbol,timeframe,start,count,Volume);
      return(ArrayMaximum(Volume,0,count)+start);
     }
   if(type>=MODE_TIME)
     {
      datetime Time[];
      ArraySetAsSeries(Time,true);
      CopyTime(symbol,timeframe,start,count,Time);
      return(ArrayMaximum(Time,0,count)+start);
      //---
     }
   return(0);
  }

iHighest
Renvoie le décalage de la valeur maximale sur un nombre spécifique de périodes en fonction du type.
CopyOpen, CopyLow, CopyHigh, CopyClose, CopyTickVolume, CopyTime, ArrayMaximum
double iLow(string symbol,
            int timeframe,
            int shift)
double iLowMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyLow(symbol,timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
iLow
Renvoie une valeur basse pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates
int iLowest(string symbol,
            int timeframe,
            int type,
            int count=WHOLE_ARRAY,
            int start=0)
int iLowestMQL4(string symbol,
                int tf,
                int type,
                int count=WHOLE_ARRAY,
                int start=0)
  {
   if(start<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(count<=0) count=Bars(symbol,timeframe);
   if(type<=MODE_OPEN)
     {
      double Open[];
      ArraySetAsSeries(Open,true);
      CopyOpen(symbol,timeframe,start,count,Open);
      return(ArrayMinimum(Open,0,count)+start);
     }
   if(type==MODE_LOW)
     {
      double Low[];
      ArraySetAsSeries(Low,true);
      CopyLow(symbol,timeframe,start,count,Low);
      return(ArrayMinimum(Low,0,count)+start);
     }
   if(type==MODE_HIGH)
     {
      double High[];
      ArraySetAsSeries(High,true);
      CopyHigh(symbol,timeframe,start,count,High);
      return(ArrayMinimum(High,0,count)+start);
     }
   if(type==MODE_CLOSE)
     {
      double Close[];
      ArraySetAsSeries(Close,true);
      CopyClose(symbol,timeframe,start,count,Close);
      return(ArrayMinimum(Close,0,count)+start);
     }
   if(type==MODE_VOLUME)
     {
      long Volume[];
      ArraySetAsSeries(Volume,true);
      CopyTickVolume(symbol,timeframe,start,count,Volume);
      return(ArrayMinimum(Volume,0,count)+start);
     }
   if(type>=MODE_TIME)
     {
      datetime Time[];
      ArraySetAsSeries(Time,true);
      CopyTime(symbol,timeframe,start,count,Time);
      return(ArrayMinimum(Time,0,count)+start);
     }
//---
   return(0);
  }

iLowest
Renvoie le décalage de la valeur la plus faible sur un nombre spécifique de périodes en fonction du type.
CopyOpen, CopyLow, CopyHigh, CopyClose, CopyTickVolume, CopyTime, ArrayMinimum
double iOpen(string symbol,
             int timeframe,
             int shift)
double iOpenMQL4(string symbol,int tf,int index)

{   
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyOpen(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}
iOpen
Renvoie la valeur d'ouverture pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates
datetime iTime(string symbol,
               int timeframe,
               int shift)
datetime iTimeMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[];
   if(CopyTime(symbol, timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
iTime
Renvoie la valeur de temps pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates
double iVolume(string symbol,
               int timeframe,
               int shift)
int iVolumeMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   long Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyTickVolume(symbol, timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
iVolume
Renvoie la valeur Tick Volume pour la barre du symbole indiqué avec délai et décalage. Si l'historique local est vide (non chargé), la fonction renvoie 0.
CopyRates, MqlRates


19. Opérations Graphiques

MQL4
 MQL5Description
void HideTestIndicators(bool hide)
-HideTestIndicators
La fonction définit un indicateur masquant les indicateurs appelés par l'Expert Advisor.
int Period()
ENUM_TIMEFRAMES  Period()
Period
Renvoie le nombre de minutes déterminant la période utilisée (période du graphique).
Période
bool RefreshRates()
-RefreshRates
Rafraîchissement des données dans des variables prédéfinies et des tableaux de séries.
string Symbol()
string Symbol()
Symbol
Renvoie une chaîne de texte avec le nom de l'instrument financier actuel.
Symbole
int WindowBarsPerChart()
int ChartGetInteger(0,CHART_VISIBLE_BARS,0)
WindowBarsPerChart
La fonction renvoie le nombre de barres visibles sur le graphique.
ChartGetInteger
string WindowExpertName()
string MQLInfoString(MQL5_PROGRAM_NAME)
WindowExpertName
Renvoie le nom de l'expert exécuté, du script, de l'indicateur personnalisé ou de la bibliothèque, selon le programme MQL4 à partir duquel cette fonction a été appelée.
MQLInfoString

int WindowFind(string name)
int WindowFindMQL4(string name)
  {
   int window=-1;
   if((ENUM_PROGRAM_TYPE)MQLInfoInteger(MQL5_PROGRAM_TYPE)==PROGRAM_INDICATOR)
     {
      window=ChartWindowFind();
     }
   else
     {
      window=ChartWindowFind(0,name);
      if(window==-1) Print(__FUNCTION__+"(): Error = ",GetLastError());
     }
   return(window);
  }
WindowFind
Si l'indicateur avec le nom a été trouvé, la fonction renvoie l'index de la fenêtre comprenant cet indicateur indiqué, sinon elle renvoie -1.
ChartWindowFind, MQLInfoInteger
int WindowFirstVisibleBar()
int ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0)
WindowFirstVisibleBar
La fonction renvoie le premier numéro de barre visible dans la fenêtre graphique actuelle.
ChartGetInteger
int WindowHandle(string symbol,
                 int timeframe)
int WindowHandleMQL4(string symbol,
                     int tf)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   long currChart,prevChart=ChartFirst();
   int i=0,limit=100;
   while(i<limit)
     {
      currChart=ChartNext(prevChart);
      if(currChart<0) break;
      if(ChartSymbol(currChart)==symbol
         && ChartPeriod(currChart)==timeframe)
         return((int)currChart);
      prevChart=currChart;
      i++;
     }
   return(0);
  }
WindowHandle
Renvoie le handle de fenêtre système du graphique indiqué.
ChartFirst, ChartNext, ChartSymbol, ChartPeriod
bool WindowIsVisible(int index)
bool ChartGetInteger(0,CHART_WINDOW_IS_VISIBLE,index)
WindowIsVisible
Renvoie TRUE si la sous-fenêtre du graphique est visible, sinon renvoie FALSE.
ChartGetInteger
int WindowOnDropped()
int ChartWindowOnDropped()
WindowOnDropped
Renvoie l'index de la fenêtre où l'expert, l'indicateur personnalisé ou le script a été déposé.
ChartWindowOnDropped
double WindowPriceMax(int index=0)
double ChartGetDouble(0,CHART_PRICE_MAX,index)
WindowPriceMax
Renvoie la valeur maximale de l'échelle verticale de la sous-fenêtre indiquée du graphique actuel (fenêtre de graphique principale 0, les sous-fenêtres des indicateurs sont numérotées à partir de 1).
ChartGetDouble
double WindowPriceMin(int index=0)
double ChartGetDouble(0,CHART_PRICE_MIN,index)
WindowPriceMin
Renvoie la valeur minimale de l'échelle verticale de la sous-fenêtre indiquée du graphique actuel (fenêtre de graphique principale 0, les sous-fenêtres des indicateurs sont numérotées à partir de 1).
ChartGetDouble
double WindowPriceOnDropped()
double ChartPriceOnDropped()
WindowPriceOnDropped
Renvoie la partie prix du point du graphique où l'expert ou le script a été déposé.
ChartPriceOnDropped
void WindowRedraw()
void ChartRedraw(0)
WindowRedraw
Redessine forcément le graphique actuel.
ChartRedraw
bool WindowScreenShot(string filename,
                      int size_x,
                      int size_y,
                      int start_bar=-1,
                      int chart_scale=-1,
                      int chart_mode=-1)
bool WindowScreenShotMQL4(string filename,
                          int size_x,
                          int size_y,
                          int start_bar=-1,
                          int chart_scale=-1,
                          int chart_mode=-1)
  {
   if(chart_scale>0 && chart_scale<=5)
      ChartSetInteger(0,CHART_SCALE,chart_scale);
   switch(chart_mode)
     {
      case 0: ChartSetInteger(0,CHART_MODE,CHART_BARS);
      case 1: ChartSetInteger(0,CHART_MODE,CHART_CANDLES);
      case 2: ChartSetInteger(0,CHART_MODE,CHART_LINE);
     }
   if(start_bar<0)
      return(ChartScreenShot(0,filename,size_x,size_y,ALIGN_RIGHT));
   else
      return(ChartScreenShot(0,filename,size_x,size_y,ALIGN_LEFT));
  }
WindowScreenShot
Enregistre la capture d'écran du graphique actuel sous forme de fichier GIF.
ChartSetInteger, ChartScreenShot
datetime WindowTimeOnDropped()
datetime ChartTimeOnDropped()
WindowTimeOnDropped
Renvoie l'heure du point du graphique où l'expert ou le script a été déposé.
ChartTimeOnDropped
int WindowsTotal()
int ChartGetInteger(0,CHART_WINDOWS_TOTAL)
WindowsTotal
Renvoie le nombre de fenêtres indicatrices sur le graphique (y compris le graphique principal).
ChartGetInteger
int WindowXOnDropped()
int ChartXOnDropped()
WindowXOnDropped
Renvoie la valeur sur l'axe X en pixels pour le point de la zone client de la fenêtre du graphique auquel l'expert ou le script a été déposé.
ChartXOnDropped
int WindowYOnDropped()
int ChartYOnDropped()
WindowYOnDropped
Renvoie la valeur sur l'axe Y en pixels pour le point de la zone client de la fenêtre du graphique auquel l'expert ou le script a été déposé.
ChartYOnDropped

Conclusion

  1. Nous n'avons pas pris en compte les fonctions de trading, car dans MQL5 le concept est différent, et l'original devrait être utilisé ! Il est possible de les convertir, mais la logique de trading doit être modifiée. En d'autres termes, il n'y a aucun sens à les convertir.
  2. La conversion de programmes d'une langue à une autre est toujours associée à une perte de fonctionnalité et de performance. Par conséquent, utilisez ce guide pour la recherche rapide des fonctions analogues.
  3. J'ai l'intention d’élaborer l'émulateur MQL4, qui vous permettra d'exécuter vos programmes MQL4 dans le nouveau terminal client MetaTrader 5.

Crédits : keiji, A. Williams.

Traduit du russe par MetaQuotes Ltd.
Article original : https://www.mql5.com/ru/articles/81

Fichiers joints |
initmql4.mqh (7.5 KB)
Création d'un Indicateur Multidevise à l'Aide d'un Certain Nombre de Tampons d'Indicateurs Intermédiaires Création d'un Indicateur Multidevise à l'Aide d'un Certain Nombre de Tampons d'Indicateurs Intermédiaires
Il y a eu récemment un intérêt grandissant pour les analyses de bloc du marché FOREX. MQL5 ouvre de nouveaux horizons de recherche des tendances du mouvement des paires de devises. Une caractéristique clé de MQL5, qui le distingue de MQL4, est la possibilité d'utiliser un nombre illimité de tampons d'indicateurs. Cet article décrit un exemple de création d'un indicateur multi-devises.
MetaTrader 5 Publication des prévisions de trading et des relevés de trading en direct par e-mail sur les blogs, les réseaux sociaux et les sites internet dédiés MetaTrader 5 Publication des prévisions de trading et des relevés de trading en direct par e-mail sur les blogs, les réseaux sociaux et les sites internet dédiés
Cet article vise à présenter des solutions prêtes à l'emploi pour la publication de prévisions à l'aide de MetaTrader 5. Il couvre un éventail d'idées : de l'utilisation de sites Web dédiés pour la publication des relevés MetaTrader à la création de son propre site Web sans pratiquement aucune expérience de programmation Web nécessaire et enfin à l'intégration à un service de micro-blogging de réseau social qui permet à de nombreux lecteurs de rejoindre et de suivre les prévisions. Toutes les solutions présentées ici sont 100% gratuites et peuvent être configurées par toute personne ayant une connaissance de base des services e-mail et ftp. Il n'y a aucun obstacle à utiliser les mêmes techniques pour les services d'hébergement professionnel et de prévision des échanges de trade.
Un Gestionnaire de Commande  Virtuelle pour suivre les commandes  dans l'environnement MetaTrader 5 axé sur la position Un Gestionnaire de Commande Virtuelle pour suivre les commandes dans l'environnement MetaTrader 5 axé sur la position
Cette bibliothèque de classes peut être ajoutée à un Expert Advisor MetaTrader 5 pour lui permettre d'être écrite avec une approche axée sur les commandes largement comparable à MetaTrader 4, par rapport à l'approche axée sur la position de MetaTrader 5. Il le fait en gardant une trace des commandes virtuelles sur le terminal client MetaTrader 5, tout en maintenant un arrêt de protection du courtier pour chaque position pour la protection contre les catastrophes.
POO en MQL5 par exemple : Traitement des Codes d'Avertissement et d'Erreur POO en MQL5 par exemple : Traitement des Codes d'Avertissement et d'Erreur
L'article décrit un exemple de création d'une classe pour travailler avec les codes de retour du serveur trade et toutes les erreurs qui se produisent lors de l'exécution du programme MQL. Lisez l'article et vous apprendrez à travailler avec des classes et des objets en MQL5. En même temps, c'est un outil pratique pour gérer les erreurs ; et vous pouvez modifier davantage cet outil en fonction de vos besoins spécifiques.