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

 
Slava:

テスターのログやエージェントのログ(最初の24個で十分です)は閲覧できるのでしょうか?

はい、もちろんです。MT5 (build 2045) 同じ問題です。
そして、MT5(ビルド2009)-すべてOKです。
もしかしたら、MT5(ビルド2009)と比べて、特にローカルエージェントが起動しているかどうかを判断するロジックに変更があったのかもしれません(例えば、ネットワークエージェント検出のロジックに持ち込むなど)...。

ファイル:
 

MT5。ビルド2055。
TFを変更すると、ChartGetDouble(0,CHART_PRICE_MAX), ChartGetDouble(0,CHART_PRICE_MIN) 関数が正しく実行されない(0が書き込まれる)。
そして、インジケータを起動すると初回から正しく書き込まれます。そして、TFをシフトしたとき、毎月のTFは常に0、他のTFは最初時々0になり、その後正規化されます。

#property indicator_chart_window
#property indicator_plots   1 
#property indicator_buffers 1

int OnInit()
  {
  Print(EnumToString(_Period) +":  PriceMax="+string(ChartGetDouble(0,CHART_PRICE_MAX))+";  PriceMin="+string(ChartGetDouble(0,CHART_PRICE_MIN)));
   return(INIT_SUCCEEDED);
  }
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
   return(rates_total);
  }

の結果です。

2019.05.20 02:30:31.689 TestMinMax (NZDUSD,MN1) PERIOD_MN1:  PriceMax=0.8995;  PriceMin=0.3258  // первый раз нормально
2019.05.20 02:30:37.492 TestMinMax (NZDUSD,W1)  PERIOD_W1:  PriceMax=0.8995;  PriceMin=0.3258
2019.05.20 02:30:39.233 TestMinMax (NZDUSD,MN1) PERIOD_MN1:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:30:41.838 TestMinMax (NZDUSD,H4)  PERIOD_H4:  PriceMax=0.6986;  PriceMin=0.6352
2019.05.20 02:30:43.237 TestMinMax (NZDUSD,MN1) PERIOD_MN1:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:30:51.404 TestMinMax (NZDUSD,M1)  PERIOD_M1:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:30:54.108 TestMinMax (NZDUSD,MN1) PERIOD_MN1:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:30:57.420 TestMinMax (NZDUSD,M5)  PERIOD_M5:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:31:00.537 TestMinMax (NZDUSD,M15) PERIOD_M15:  PriceMax=0.0;  PriceMin=0.0
2019.05.20 02:31:02.512 TestMinMax (NZDUSD,M30) PERIOD_M30:  PriceMax=0.679;  PriceMin=0.6477000000000001
2019.05.20 02:31:03.780 TestMinMax (NZDUSD,M15) PERIOD_M15:  PriceMax=0.6689000000000001;  PriceMin=0.649
2019.05.20 02:31:05.977 TestMinMax (NZDUSD,M5)  PERIOD_M5:  PriceMax=0.6593;  PriceMin=0.6502
2019.05.20 02:31:07.502 TestMinMax (NZDUSD,M1)  PERIOD_M1:  PriceMax=0.6541;  PriceMin=0.6508
2019.05.20 02:31:10.136 TestMinMax (NZDUSD,MN1) PERIOD_MN1:  PriceMax=0.0;  PriceMin=0.0
ファイル:
 

https://www.mql5.com/ru/docs/basis/types/classes

offsetof – это специальная команда, которая непосредственно связана в атрибутом pack. Она позволяет получить смещение члена от начала структуры.

struct Parent{ 
      char              c;    // sizeof(char)=1 
};
     
struct Children pack(2) : Parent{ 
      short             s;   // sizeof(short)=2 
};

void OnStart(){ 
//--- объявим переменную типа Children 
   Children child;   
//--- узнаем смещения от начала структуры  
   Print("offsetof(child.c)=",offsetof(child.c)); 
   Print("offsetof(child.s)=",offsetof(child.s));
}   


最初はオフセットフの存在を知らなかったので、驚きました。
しかし、現実はすべてを置き去りにしてしまった。

'offsetof' - 関数が定義されていない

 
Sergey Dzyublik:

https://www.mql5.com/ru/docs/basis/types/classes

最初はオフセットフの存在を知らなかったので、驚きました。
しかし、現実はすべてを置き去りにしてしまった。

'offsetof' - 関数が定義されていない

あなた自身が書いている

#include <TypeToBytes.mqh>

Print("offsetof(child.c)=",_OFFSET(child, c)); 
Print("offsetof(child.s)=",_OFFSET(child, s));
 

Signalsセクションからシグナルを開くと、インフォグラフィックの例を見ることができます。



通常、インフォグラフィックの目的は、分析対象物の一連の特性の長所と短所をエンドユーザーに伝えることである。
しかし、このインフォグラフィックの本質は、100%のドローダウンを100%の結果としてチャート上に表示することである。
また、同じチャート内で同じ指標が2回使用されています。1回目はプラスで、2回目はマイナスで表示されています(「利益が出ている取引」と「負けている取引」の指標)。

変更を提案する。
1.最大ドローダウン」「最大入金額」「負けトレード」の指標にカウントダウンを導入(小さい値-チャート上の指標の値が大きくなる)。
2.重複している指標(「利益が出ている取引」または「負けている取引」)のいずれかを新しい指標(例えば、買いから売りまでの量の平均偏差など)に置き換えます。
3.最大ドローダウン」や「最大入金負荷」など、特定の指標については、チャート上の どこにでもある%目盛りを対数などの表示目盛りに 置き換えます。信号の魅力に対する指標の影響度を高めることが目的です。

 
class A{
   int  data;
};

struct Wrap{
   A arr[];
};
   
   
void OnStart(){  
   Wrap data_1;
   ArrayResize(data_1.arr, 10);
   
   Wrap data_2 = data_1;
   PRINT(ArraySize(data_2.arr));      // result: 10
   
   A arr[];
   PRINT(ArrayCopy(arr, data_1.arr)); //'arr' - structures or classes containing objects are not allowed
}


構造体はディープコピーができるのに、ArrayCopyは クラスがコピーコンストラクタを持っていても何もできず、コンパイルエラーに なるのはなぜですか?
"普通じゃない、不公平だ!"©

 
bool  ArrayInsert( 
   void&        dst_array[],          // receiving array 
   const void&  src_array[],          // source array 
   uint         dst_start,            // receiver array index to be inserted 
   uint         src_start=0,          // source array index to be copied 
   uint         count=WHOLE_ARRAY     // number of elements to insert 
   );
int  ArrayCopy( 
   void&        dst_array[],         // destination array 
   const void&  src_array[],         // source array 
   int          dst_start=0,         // index starting from which write into destination array 
   int          src_start=0,         // first index of a source array 
   int          count=WHOLE_ARRAY    // number of elements 
   );

ほぼ「同じ」機能での違い。
1. ArrayInsert のデフォルトパラメータがない。
2.パラメータの記述が「標準的」でないこと。

同じパラメータに異なるデータ型(int, uint)を使用することは、互換性を参照しながら理解することができます。
 
Sergey Dzyublik:
ArrayInsert のデフォルトパラメータがない。
そこには必要ないのです。
しかし、この関数は、追加された要素の数を返すべきなのに、boolを返しているのは...。
 
Sergey Dzyublik:


構造体はディープコピーができるのに、ArrayCopyは クラスがコピーコンストラクタを持っていても何もできず、コンパイルエラーに なるのはなぜですか?
"普通じゃない、不公平だ!"©

自分で本格的なArrayCopyを実装することになりました。
私はそうは思わないが、もしかしたら誰かが役に立つかもしれない...。

#define  PRINT(x) ; Print(#x, ":", string(x))

template<typename T>
uint  ArrayCopy_bypass( 
   T&            dst_array[],         // destination array 
   const T&      src_array[],         // source array 
   uint          dst_start=0,         // index starting from which write into destination array 
   uint          src_start=0,         // first index of a source array 
   uint          count=WHOLE_ARRAY    // number of elements 
   )
{
   uint src_size = ArraySize(src_array);
   uint dst_size = ArraySize(dst_array);
   bool src_array_is_dynamic = ArrayIsDynamic(src_array);
   bool dst_array_is_dynamic = ArrayIsDynamic(dst_array);
   
   // validate input parameters
   if(src_size <= src_start 
      || ( !dst_array_is_dynamic && (dst_size <= dst_start))){
      return 0;
   }
   
   uint max_allowed_array_size = uchar(INT_MAX);
   uint same_array_check_min_count_limit = 5;
   
   //--- the same array could be passed to dst_array and src_array parameters
   bool same_array_is_used = true;
   bool dst_array_resize_was_applied = false;
   if (src_size != dst_size || src_array_is_dynamic != dst_array_is_dynamic){
      same_array_is_used = false;
   }
   
   //--- normalize copy count based on src_array data
   if(count == uint(WHOLE_ARRAY) || count > src_size - src_start){
      count = src_size - src_start;
   }
   
   //--- normalize copy count based on dst_start data
   uint dst_required_size = dst_start + count;
   if (dst_required_size > max_allowed_array_size){
      return 0;
   }
   
   if(dst_size <= dst_required_size){
      if(dst_array_is_dynamic){
         ArrayResize(dst_array, dst_required_size);
         dst_array_resize_was_applied = true;
         
         dst_size = ArraySize(dst_array);
         src_size = ArraySize(src_array);
         
         if(same_array_is_used && src_size != dst_size){
            same_array_is_used = false;
         }
      }    
      count = dst_size - dst_start;
   }
   
   //--- check copy count
   if(count == 0){
      return 0;
   }
   
   //--- the same array could be passed to dst_array and src_array parameters, let's confirm it
   if(count >= same_array_check_min_count_limit 
         && same_array_is_used 
         && !dst_array_resize_was_applied)
   {
      if(dst_array_is_dynamic && dst_size + 1 <= max_allowed_array_size){
         ArrayResize(dst_array, dst_size + 1);
         dst_array_resize_was_applied = true;
         
         if(ArraySize(src_array) != dst_size + 1){
            same_array_is_used = false;
         }
         ArrayResize(dst_array, dst_size);
      }
   }
   
   //copy arrays
   if(same_array_is_used){
      T src_copy[];
      ArrayResize(src_copy, count);
      
      for(uint i = 0; i < count; i++){
         src_copy[i] = src_array[src_start + i];
      }
      
      for(uint i = 0; i < count; i++){
         dst_array[dst_start + i] = src_copy[i];
      }
   }else{
      for(uint i = 0; i < count; i++){
         dst_array[dst_start + i] = src_array[src_start + i];
      }
   }
   return count;
}
   
   
class A{
   uchar data;
};
   
   
void OnStart(){
   uchar test_data[10] = {0,1,2,3,4,5,6,7,8,9};
   
   PRINT("TEST 1 (Static)");     
   uchar data_1[8]; 
   
   PRINT(ArrayCopy_bypass(data_1, test_data));
   ArrayPrint(data_1);
   
   PRINT(ArrayCopy_bypass(data_1, test_data, 1, 0, 1));
   ArrayPrint(data_1);
   
   PRINT(ArrayCopy_bypass(data_1, test_data, 5));
   ArrayPrint(data_1);
   
   PRINT(ArrayCopy_bypass(data_1, test_data, 30, 8, 5));
   ArrayPrint(data_1);
   
   
   PRINT("TEST 2 (DYNAMIC)");  
   uchar data_2[]; 
   
   PRINT(ArrayCopy_bypass(data_2, test_data));
   ArrayPrint(data_2);
   
   PRINT(ArrayCopy_bypass(data_2, test_data, 1, 0, 1));
   ArrayPrint(data_2);
   
   PRINT(ArrayCopy_bypass(data_2, test_data, 5));
   ArrayPrint(data_2);
   
   PRINT(ArrayCopy_bypass(data_2, test_data, 30, 8, 5));
   ArrayPrint(data_2);
   
   
   A data_a1[10];
   A data_a2[];
   ArrayCopy_bypass(data_a2, data_a1);            //10
   //PRINT(ArrayCopy(data_a2, data_a1));          //'data_a2' - structures or classes containing objects are not allowed
}


結果

2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      TEST 1 (Static):TEST 1 (Static)
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_1,test_data):8
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 1 2 3 4 5 6 7
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_1,test_data,1,0,1):1
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 5 6 7
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_1,test_data,5):3
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 0 1 2
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_1,test_data,30,8,5):0
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 0 1 2
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      TEST 2 (DYNAMIC):TEST 2 (DYNAMIC)
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_2,test_data):10
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 1 2 3 4 5 6 7 8 9
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_2,test_data,1,0,1):1
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 5 6 7 8 9
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_2,test_data,5):10
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 0 1 2 3 4 5 6 7 8 9
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      ArrayCopy_bypass(data_2,test_data,30,8,5):2
2019.05.21 00:27:59.870 Test_ArrayCopy (EURUSD,H1)      0 0 2 3 4 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 9
 
こんにちは。
どなたか、最後のProfitウィンドウのバランスシートレポートに、スワップやコミッションも含める方法を教えてください。
あるいは、どうすればいいのか?
利益を見てから、手数料やスワップを引くべきと気づくのは不便です。ひどく迷惑です!