Errores, fallos, preguntas - página 269

 
AndrNuda:
Sois muy lentos :) Las caídas no son falsas, pero todo funciona. Estás buscando en el lugar equivocado. )))) Hay una función correcta.
¿Inteligente?
 
BoraBo:

Estoy tratando de averiguar por qué ArrayIsSeries(High) es siempre falso

La ayuda de esta función dice(https://www.mql5.com/ru/docs/array/arrayisseries)

Valor de retorno

Devuelve true si el array que se está comprobando es un array de series temporales, en caso contrario devuelve false. Las matrices pasadas como parámetro a OnCalculate() deben ser comprobadas por el orden en que se accede a los elementos de la matriz con ArrayGetAsSeries().

El array que has declarado no es una serie temporal y no puede convertirse en una bajo ninguna circunstancia. Las series de tiempo son matrices definidas en tiempo de ejecución, por ejemplo, en la función OnCalculate():

int OnCalculate (const int rates_total,      // размер входных таймсерий
                 const int prev_calculated,  // обработано баров на предыдущем вызове
                 const datetime& time[],     // Time
                 const double& open[],       // Open
                 const double& high[],       // High
                 const double& low[],        // Low
                 const double& close[],      // Close
                 const long& tick_volume[],  // Tick Volume
                 const long& volume[],       // Real Volume
                 const int& spread[]         // Spread
   )
Документация по MQL5: Операции с массивами / ArrayIsSeries
Документация по MQL5: Операции с массивами / ArrayIsSeries
  • www.mql5.com
Операции с массивами / ArrayIsSeries - Документация по MQL5
 
Rosh:

La ayuda de esta función dice(https://www.mql5.com/ru/docs/array/arrayisseries)

El array que has declarado no es una serie temporal y no puede convertirse en una bajo ninguna circunstancia. Las series de tiempo son matrices predefinidas en tiempo de ejecución, por ejemplo en la función OnCalculate():

ArrayGetAsSeries no funciona como se pretende.
 
AlexSTAL:
ArrayGetAsSeries no funciona como se pretende.
La función ArrayGetAsSeries sólo cambia la dirección de indexación, pero no convierte el array en una serie de tiempo. ¿Qué se pretende conseguir con esta función?
 
Rosh:
Las series de tiempo son matrices predefinidas en tiempo de ejecución, por ejemplo, en OnCalculate():
int OnCalculate (const int rates_total,      // размер входных таймсерий
                 const int prev_calculated,  // обработано баров на предыдущем вызове
                 const datetime& time[],     // Time
                 const double& open[],       // Open
                 const double& high[],       // High
                 const double& low[],        // Low
                 const double& close[],      // Close
                 const long& tick_volume[],  // Tick Volume
                 const long& volume[],       // Real Volume
                 const int& spread[]         // Spread
   )


Lo que sobre esto está escrito en la ayuda:

Примечание

Для проверки массива на принадлежность к таймсерии следует применять функцию ArrayIsSeries(). Массивы ценовых данных, переданных в качестве входных параметров в функцию OnCalculate(), не обязательно имеют направление индексации как у таймсерий. Нужное направление индексации можно установить функцией ArraySetAsSeries().

 
joo:

Lo que sobre esto está escrito en la ayuda:


Ejecute dicho indicador y lo comprobará por sí mismo:

//+------------------------------------------------------------------+
//|                                           CheckArrayIsSeries.mq5 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//---- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  Red
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         Label1Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void checkArray(const double & array[])
  {
   if(ArrayGetAsSeries(array))
     {
      Print("array can use as timeseria");
     }
     else
     {
      Print("array can not use as timeseria!!!");
     }
     
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   if(ArrayIsSeries(open))
     {
      Print("open[] is timeseria");
      checkArray(open);
     }
   else
     {
        {
         Print("open[] is timeseria!!!");
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Rosh:
La función ArrayGetAsSeries sólo cambia el sentido de la indexación, pero no convierte un array en una serie temporal. ¿Qué se pretende conseguir con esta función?

Esta función comprueba la dirección, no el cambio.

1) Sin inicialización

double Buf[];
void OnStart()
  {
   ArrayResize(Buf, 3);

   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf));             // ArrayGetAsSeries(Buf): false
   
   // Меняем направление на обратный порядок
   Print("Установка в true прошла: ", ArraySetAsSeries(Buf, true));     // Установка в true прошла: true
   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf));             // ArrayGetAsSeries(Buf): false
   
   // Меняем направление на прямой порядок
   Print("Установка в false прошла: ", ArraySetAsSeries(Buf, false));   // Установка в false прошла: true
   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf));             // ArrayGetAsSeries(Buf): false
  }

2) Con la inicialización

double Buf[];
void OnStart()
  {
   ArrayResize(Buf, 3);
   Buf[0] = 0; Buf[1] = 1; Buf[2] = 2;

   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf));             // ArrayGetAsSeries(Buf): false
   
   // Меняем направление на обратный порядок
   Print("Установка в true прошла: ", ArraySetAsSeries(Buf, true));     // Установка в true прошла: true
   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf), " [", Buf[0], ",", Buf[1], ",", Buf[2], "]"); // ArrayGetAsSeries(Buf): true [2,1,0]
   
   // Меняем направление на прямой порядок
   Print("Установка в false прошла: ", ArraySetAsSeries(Buf, false));   // Установка в false прошла: true
   Print("ArrayGetAsSeries(Buf): ", ArrayGetAsSeries(Buf), " [", Buf[0], ",", Buf[1], ",", Buf[2], "]"); // ArrayGetAsSeries(Buf): false [0,1,2]
  }

3) El código anterior, sólo con la función ArrayGetAsSeries obteniendo la dirección de indexación del array

double High[];
#include <Indicators\TimeSeries.mqh>
void OnStart()
  {
   Print("ArrayGetAsSeries(High) ",ArrayGetAsSeries(High));                   // ArrayGetAsSeries(High) false

   CiHigh z;

   int count=3;
   if(z.Create(_Symbol,_Period)==true)
     {
      if(z.GetData(0,count,High)==count)
        {
         for(int i=0; i<count; i++) Print(i,"=",High[i]);
         Print("ArraySetAsSeries(High,true) ",ArraySetAsSeries(High,true));   // ArraySetAsSeries(High,true) true
         Print("ArrayGetAsSeries(High) true = ",ArrayGetAsSeries(High));      // ArrayGetAsSeries(High) true = false
         for(int i=0; i<count; i++) Print(i,"=",High[i]);
         Print("ArraySetAsSeries(High,false) ",ArraySetAsSeries(High,false)); // ArraySetAsSeries(High,false) true
         Print("ArrayGetAsSeries(High) false = ",ArrayGetAsSeries(High));     // ArrayGetAsSeries(High) false = false
         for(int i=0; i<count; i++) Print(i,"=",High[i]);
        }
      else
         Print("Не удалось получить ",count," данных таймсерии.");
     }
   else Print("Ошибка создания таймсерии.");
   Print("ArrayGetAsSeries(High) ",ArrayGetAsSeries(High));                   // ArrayGetAsSeries(High) false
   Print("GetLastError() ",GetLastError());
  }
En el servicio de atención al cliente me equivoqué en el nombre de la función sólo


 
Rosh:

Ejecute dicho indicador y lo comprobará por sí mismo:

Es comprensible. Y mi pregunta no se refería a errores, todo funciona como está escrito en la ayuda:

Примечание

Для проверки массива на принадлежность к таймсерии следует применять функцию ArrayIsSeries(). Массивы ценовых данных, переданных в качестве входных параметров в функцию OnCalculate(), не обязательно имеют направление индексации как у таймсерий. Нужное направление индексации можно установить функцией ArraySetAsSeries().


La pregunta surgió por la discrepancia entre lo que la ayuda resaltó en color y negrita y lo que usted dijo:

Rosh:
Las series de tiempo son matrices predefinidas en tiempo de ejecución, por ejemplo en OnCalculate():

Por eso lo hago en OnCalculate():

    //--------------------------------------
    if (ArrayGetAsSeries(time)!=true)
      ArraySetAsSeries(time,true);
    if (ArrayGetAsSeries(open)!=true)
      ArraySetAsSeries(open,true);
    if (ArrayGetAsSeries(high)!=true)
      ArraySetAsSeries(high,true);
    if (ArrayGetAsSeries(low)!=true)
      ArraySetAsSeries(low,true);
    if (ArrayGetAsSeries(close)!=true)
      ArraySetAsSeries(close,true);
    //--------------------------------------
 
Rosh:

La ayuda de esta función dice(https://www.mql5.com/ru/docs/array/arrayisseries)

El array que has declarado no es una serie temporal y no puede convertirse en una bajo ninguna circunstancia. Las series de tiempo son matrices predefinidas, por ejemplo en la función OnCalculate():

La comprobación tampoco funciona en el indicador.

//+------------------------------------------------------------------+
//|                                                    ind_proba.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   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[])
  {
//---
   int count=3;
   int i=0;
   int limit;
//   bool printCom;

   if(prev_calculated>0)
     {
      limit=1;
     }
   else
     {
      Print("rates_total  ",rates_total,"  prev_calculated  ",prev_calculated);
      for(i=0; i<count; i++) Print(i,"=",open[i]);
      Print("ArraySetAsSeries(open,true) ",ArraySetAsSeries(open,true));
      Print("ArrayIsSeries(open) true = ",ArrayIsSeries(open));
      Print("ArrayGetAsSeries(open) true = ",ArrayGetAsSeries(open));
      for(i=0; i<count; i++) Print(i,"=",open[i]);
      Print("ArraySetAsSeries(open,false) ",ArraySetAsSeries(open,false));
      Print("ArrayIsSeries(open) false = ",ArrayIsSeries(open));
      Print("ArrayGetAsSeries(open) false = ",ArrayGetAsSeries(open));
      for(i=0; i<count; i++) Print(i,"=",open[i]);
     }
   Print("GetLastError() ",GetLastError());
//--- return value of prev_calculated for next call

   return(rates_total);
  }
//+------------------------------------------------------------------+

Además,prev_calculado ya no funciona, siempre es 0:

 

Sí, creo que con estas funciones ya se han solucionado.


Pero como un deseo, para que no se me olvide - en el editor, cuando se le pide después de escribir tres o cuántos caracteres, al hacer clic en pie en la primera línea de la lista no se elimina de la lista. Acostumbrados a ser tan ya como en el estudio, creo que muchos se "molestarán" si no se hace de la misma manera que en el estudio. EN MI OPINIÓN.

Razón de la queja: