Errores, fallos, preguntas - página 2465

 
Slava:

¿Se pueden ver los registros de los probadores y de los agentes (los primeros 24 son suficientes)?

Sí, por supuesto. MT5 (build 2045) mismo problema.
Y MT5 (build 2009) - todo está bien.
Tal vez hubo algunos cambios en comparación con MT5 (build 2009), en particular en la lógica de determinar si un agente local se está ejecutando o no (por ejemplo, lo llevó a la lógica de la detección de agentes de red)...

Archivos adjuntos:
 

MT5. build 2055.
Las funciones ChartGetDouble(0,CHART_PRICE_MAX) y ChartGetDouble(0,CHART_PRICE_MIN) se ejecutan incorrectamente (escriben ceros) al cambiar la TF.
Y escribe correctamente la primera vez al iniciar el indicador. Entonces, cuando el TF se desplaza en el TF mensual siempre es cero, en otros a veces al principio, luego se normaliza.

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

resultado:

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
Archivos adjuntos:
 

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


Al principio me sorprendió, porque no sabía que existía el offsetof.
Pero la realidad puso todo en su sitio:

'offsetof' - función no definida

 
Sergey Dzyublik:

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

Al principio me sorprendió porque desconocía la existencia de offsetof.
Pero la realidad puso todo en su sitio:

'offsetof' - función no definida

Usted mismo ha escrito

#include <TypeToBytes.mqh>

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

Si abre una señal de la sección Señales, podrá ver un ejemplo de infografía:



Normalmente, el objetivo de una infografía es transmitir al usuario final los pros y los contras de un conjunto de propiedades del objeto analizado.
Sin embargo, la esencia de esta infografía no está clara, cuando una reducción del 100% se muestra como un resultado del 100% en el gráfico.
También el mismo indicador se utiliza dos veces dentro del mismo gráfico: una vez en positivo y la segunda en negativo (indicadores de "Operaciones Rentables" y "Operaciones Perdedoras").

Cambios propuestos:
1. Introducir una cuenta atrás para los indicadores "Reducción máxima", "Carga máxima del depósito", "Operaciones perdedoras" (cuanto menor sea el valor, mayor será el valor del indicador en el gráfico);
2. Sustituya uno de los indicadores duplicados ("Operaciones rentables" o "Operaciones perdedoras") por un nuevo indicador (por ejemplo, la desviación media de la cantidad de compra a la de venta, o cualquier otra cosa);
3. Para ciertos indicadores, como "Reducción máxima" y "Carga máxima de depósito", sustituya la omnipresente escala de % en el gráfico por una escala logarítmica o de otro tipo. El objetivo es aumentar el impacto del indicador en el atractivo de la señal.

 
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
}


¿Por qué las estructuras pueden hacer una copia profunda, peroArrayCopy, incluso cuando la clase tiene un constructor de copia, no puede hacer nada y da un error de compilación?
"¡No es normal, no es justo!" ©

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

Diferencias en funciones casi "idénticas":
1. no hay parámetro por defecto para ArrayInsert.
2. falta de una descripción "estándar" de los parámetros.

Se puede entender el uso de diferentes tipos de datos para los mismos parámetros (int, uint), refiriéndose a la compatibilidad.
 
Sergey Dzyublik:
No hay parámetro por defecto para ArrayInsert.
No es necesario allí.
Pero el hecho de que la función devuelva un bool, cuando debería devolver el número de elementos añadidos...
 
Sergey Dzyublik:


¿Por qué las estructuras pueden hacer una copia profunda, peroArrayCopy, incluso cuando la clase tiene un constructor de copia, no puede hacer nada y da un error de compilación?
"¡No es normal, no es justo!" ©

Tuve que implementar un ArrayCopy completo yo mismo.
No lo creo, pero tal vez alguien pueda encontrarlo útil...

#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
}


Resultado:

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
 
Buenas tardes.
¿Puede alguien decirme cómo hacer que el informe de balance en la última ventana de Beneficios incluya también el intercambio y las comisiones?
¿O cómo hacerlo?
No es conveniente mirar el beneficio y luego te das cuenta de que hay que restar la comisión y los swaps. Es terriblemente molesto.