エラー、バグ、質問 - ページ 297

 
alexluek:
全ペアのアルパリ

私の記憶違いでなければ、アルパリの最低ロットは0.10です。

しかし、妥当性・検証のためには、上記のように

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

テキストファイルから長い行を 読み込むとエラーになる

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();}

私は

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


早めの修正をお願いします。

 

データウィンドウに バッファ名を表示させる方法を教えてください。

//+------------------------------------------------------------------+
//|                                                    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);
  }
//+------------------------------------------------------------------+
 
プログラムのプロパティの 例を参照してください。
 
Rosh:
プログラムのプロパティの 例を参照してください。

ありがとうございます。
 
BoraBo:

データウィンドウにバッファ名を表示させる方法を教えてください。

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

テキストファイルから長い行を 読み込むとエラーになる

早急な修正をお願いします。

メッセージありがとうございます、修正しました。
 
mql5:
メッセージありがとうございます、訂正しました。
ありがとうございました。新しいビルドはいつ来るのか?
 

標準のCChartクラスは不具合があります。

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

スクリプトを実行すると、ほら、チャートが風で吹き飛ばされる :o)

エラーメッセージが 表示されることなく、チャートが削除されます。

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

標準のCChartクラスは不具合があります。

スクリプトを実行すると、ほら、チャートが風で吹き飛ばされる :o)

エラーメッセージが 表示されることなく、チャートが削除されます。

スクリプトが終了すると、CChartクラスのインスタンスを含むすべてのオブジェクトが自動的に破棄されます。しかし、作成されたオブジェクトのデストラクタは、破壊処理中に呼び出されます。この例では、CChart クラスのデストラクタは次のようになります。

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

すなわち、スクリプトが実行されているチャートが閉じられる。

PSMQL5におけるオブジェクトの生成と破棄の順序 の記事を読んでください。