Erreurs, bugs, questions - page 297

 
alexluek:
Alpari pour toutes les paires

Si je ne me trompe pas, Alpari a une taille de lot minimale de 0,10.

Mais pour la validité et la vérification, comme mentionné ci-dessus, il est préférable d'utiliser

double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
 

Erreurs lors de la lecture de longues lignes à partir de fichiers texte

void testStr()
  {
   string fn= "test_str.txt",sRead,sWrite="";
   int cnStr=100,cnSymb=6000,i,fh;
   fh=FileOpen(fn,FILE_WRITE|FILE_TXT|FILE_ANSI);
   if(fh==INVALID_HANDLE) return;
   for(i=0; i<cnSymb; i++)
     {
      sWrite+=(string)(i%10);
     }
   int wrLen;
   for(i=0; i<cnStr; i++)
     {
      wrLen=FileWriteString(fh,sWrite+"\r\n")-2;
     }
   FileClose(fh);

   fh=FileOpen(fn,FILE_READ|FILE_TXT|FILE_ANSI);
   if(fh==INVALID_HANDLE) return;
   int readLen,minCn,j,error1Cn=0,error2Cn=0;
   for(i=0; i<cnStr; i++)
     {
      sRead=FileReadString(fh);
      readLen=StringLen(sRead);
      if(readLen!=wrLen)
        {
         if(error1Cn<3) Print("ERROR1 str: ",i," readLen: ",readLen,", wrLen: ",wrLen);
         error1Cn++;
        }
      int minCn=MathMin(readLen,wrLen);
      ushort chR,chW;
      for(j=0; j<minCn; j++)
        {
         chR = StringGetCharacter(sRead, j);
         chW = StringGetCharacter(sWrite, j);
         if(chR!=chW) break;
        }
      if(j!=minCn)
        {
         if(error2Cn<3) Print("ERROR2 str: ",i," symbol: ",j," chR: ",chR," chW: ",chW," readLen: ",readLen,", wrLen: ",wrLen);
         error2Cn++;
        }
     }
   FileClose(fh);
   Print("Str count: ",cnStr," str size: ",cnSymb," error1Cn: ",error1Cn," error2Cn: ",error2Cn);
  }
//---
void OnStart(){testStr();}

Je reçois

Str count: 100 str size: 6000 error1Cn: 3 error2Cn: 1
ERROR1 str: 99 readLen: 0, wrLen: 6000
ERROR1 str: 98 readLen: 0, wrLen: 6000
ERROR2 str: 0 symbol: 5373 chR: 53 chW: 51 readLen: 5998, wrLen: 6000
ERROR1 str: 0 readLen: 5998, wrLen: 6000


Veuillez le réparer dès que possible.

 

Pouvez-vous me dire comment faire pour que la fenêtre de données affiche les noms de ses tampons ?

//+------------------------------------------------------------------+
//|                                                    ind_proba.mq5 |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window

#property indicator_plots   5  //must set, can be bigger than necessary, can not be bigger than indicator_buffers
#property indicator_buffers 15 //must set, can be bigger than necessary
                               //BufferPattern
#property indicator_type1   DRAW_COLOR_BARS  //DDDDC
#property indicator_width1  2
#property indicator_color1  Blue,Red,Green

//--- input parameters
double OpenBarBuff[];   //  data buffer
double HighBarBuff[];
double LowBarBuff[];
double CloseBarBuff[];
double ColorBarBuff[];   // color buffer
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

   SetIndexBuffer(0,OpenBarBuff,INDICATOR_DATA);
   SetIndexBuffer(1,HighBarBuff,INDICATOR_DATA);
   SetIndexBuffer(2,LowBarBuff,INDICATOR_DATA);
   SetIndexBuffer(3,CloseBarBuff,INDICATOR_DATA);
   SetIndexBuffer(4,ColorBarBuff,INDICATOR_COLOR_INDEX);

   PlotIndexSetString(0,PLOT_LABEL,"Open");
   PlotIndexSetString(1,PLOT_LABEL,"High");
   PlotIndexSetString(2,PLOT_LABEL,"Low");
   PlotIndexSetString(3,PLOT_LABEL,"Close");
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   CalcBars(rates_total,prev_calculated,open,high,low,close);

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int CalcBars(const int rates_total,
             const int prev_calculated,
             const double &open[],
             const double &high[],
             const double &low[],
             const double &close[])
  {
//--- auxiliary variables
   int i=0;
//--- set position for beginning
   if(i<prev_calculated) i=prev_calculated-1;
//--- start calculations
   while(i<rates_total)
     {
      OpenBarBuff[i]=open[i];
      HighBarBuff[i]=high[i];
      LowBarBuff[i]=low[i];
      CloseBarBuff[i]=close[i];
      ColorBarBuff[i]=(double)((close[i]>open[i])?0:(close[i]<open[i])?1:2);
      i++;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Voir l'exemple sous Propriétés du programme
 
Rosh:
Voir l'exemple sous Propriétés du programme

Merci.
 
BoraBo:

Pouvez-vous me dire comment faire pour que la fenêtre de données affiche les noms de ses tampons ?

...
#property indicator_plots   1 
#property indicator_buffers 5
...
PlotIndexSetString(0,PLOT_LABEL,"Open;High;Low;Close");
...
 
BZSP:

Erreurs lors de la lecture de longues lignes à partir de fichiers texte

Veuillez réparer dès que possible.

Merci pour le message, corrigé.
 
mql5:
Merci pour le message, corrigé.
Merci ! Quand est-ce que la nouvelle construction arrive ?
 

La classe standard CChart est défaillante.

#include <Charts\Chart.mqh> // подключаем класс
void OnStart()
  {   
   CChart eur; // создаём объект
   eur.Attach(); // приатачиваем к чарту
  }

Exécutez le script et voilà, le graphique est emporté par le vent :o)

Le graphique est supprimé sans aucun message d'erreur.

Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции - Документация по MQL5
 
Urain:

La classe standard CChart est défaillante.

Exécutez le script et voilà, le graphique est emporté par le vent :o)

Le graphique est supprimé sans aucun message d'erreur.

Lorsque le script se termine, tous les objets sont détruits automatiquement, y compris une instance de la classe CChart. Mais les destructeurs des objets créés sont appelés pendant le processus de destruction. Dans notre cas, le destructeur ressemble à ceci pour la classe CChart

void CChart::Close()
  {
   if(m_chart_id!=-1)
     {
      ChartClose(m_chart_id);
      m_chart_id=-1;
     }
  }

c'est-à-dire que le graphique sur lequel le script est exécuté est fermé.

PS Lisez l'article L'ordre de création et de destruction des objets dans MQL5.

Raison: