Errores, fallos, preguntas - página 2459

 
Uladzimir Izerski:

¿Qué?

¿Nadie puede responder a mi pregunta?

¿Qué hay que dominar? Poner todo en OnInit en una función separada, que sea MyOnInit. Desde OnInit llamar a MyOnInit y desde OnChartEvent después de cambiar el campo de entrada.

Esto es lo básico, puede que necesites algo más. Tengo un indicador gratuito en el Mercado que colorea las barras o velas en función de que el MACD esté por encima o por debajo de cero. Pero si se cambia el gráfico a una línea, el número de topes necesarios ya cambia. La solución se encuentra de esta manera.

 
Uladzimir Izerski:

Así que ya has publicado el código.

Si yo soy un inepto, alguien debe ser un profesional. Todavía no lo veo.

Acepto su esfuerzo por encontrar una respuesta. Es más profundo en el entendimiento. Es decir, a nivel de los desarrolladores.


El código es una locura, pero es la única forma en que me funcionó... pero mi ordenador está muy ocupado ahora mismo...

//+------------------------------------------------------------------+
//|                                                      Probe_2.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                                 https://mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://mql5.com"
#property description "The MA "
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot MA1
#property indicator_label1  "MA 1"

#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkOrange
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1


//--- input parameters
extern int PBB=10;  //  период МА
//--- indicator buffers
double         BufferMA1[];
//--- global variables
int            period_ma1;
int            period_max;

int            handle_ma1;
string sn,sPBB;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {

   sPBB=IntegerToString(PBB);
   if(ObjectFind(0,"P2edit")!=0)
     {
      ObjectCreate(0,"P2edit",OBJ_EDIT,0,0,0);
      ObjectSetInteger(0,"P2edit",OBJPROP_XDISTANCE,300);
      ObjectSetInteger(0,"P2edit",OBJPROP_YDISTANCE,1);
      ObjectSetInteger(0,"P2edit",OBJPROP_XSIZE,70);
      ObjectSetInteger(0,"P2edit",OBJPROP_YSIZE,40);
      ObjectSetInteger(0,"P2edit",OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
      ObjectSetString(0,"P2edit",OBJPROP_TEXT,sPBB);
      ObjectSetInteger(0,"P2edit",OBJPROP_FONTSIZE,16);
      ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrGray);
      ObjectSetInteger(0,"P2edit",OBJPROP_ALIGN,ALIGN_CENTER);
      ObjectSetInteger(0,"P2edit",OBJPROP_READONLY,false);
     }
//=================//
//
   else
     {
      string get_text=ObjectGetString(0,"P2edit",OBJPROP_TEXT);
      PBB=(int)StringToInteger(get_text);
     }
//
//=================//

//--- set global variables
   period_ma1=int(PBB<1 ? 1 : PBB);
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferMA1,INDICATOR_DATA);
   ArraySetAsSeries(BufferMA1,true);
   IndicatorSetInteger(INDICATOR_DIGITS,Digits());
//--- create handle
   ResetLastError();

   Comment("Должна соответствовать зеленой, а равна= ",period_ma1);

   handle_ma1=iMA(Symbol(),PERIOD_CURRENT,period_ma1,0,1,PRICE_CLOSE);
   if(handle_ma1==INVALID_HANDLE)
     {
      Print("The iMA(",(string)period_ma1,") object was not created: Error ",GetLastError());
      return INIT_FAILED;
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_ENDEDIT)
     {
      string obj_name=sparam;
      if(StringCompare(obj_name,"P2edit")==0)
        {
         string novPBB=NULL;
         if(ObjectGetString(0,obj_name,OBJPROP_TEXT,0,novPBB))
           {
            if(StringCompare(novPBB,sPBB,false))
              {
               PBB=(int)StringToInteger(novPBB);
               ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
               ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrLime);
              }
           }

         //=================//
         //
         OnInit();
         //
         //=================//

         Print(TimeLocal(),"   ",ChartSetSymbolPeriod(0,Symbol(),PERIOD_CURRENT),"  ",BufferMA1[0]);
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//    Пробовал от сюда запускать.
//   sPBB=IntegerToString(PBB);
//   if(ObjectFind(0,"P2edit")!=0)
//    {
//       ObjectCreate(0,"P2edit",OBJ_EDIT,0,0,0);
//       ObjectSetInteger(0,"P2edit",OBJPROP_XDISTANCE,300);
//       ObjectSetInteger(0,"P2edit",OBJPROP_YDISTANCE,1);
//       ObjectSetInteger(0,"P2edit",OBJPROP_XSIZE,70);
//       ObjectSetInteger(0,"P2edit",OBJPROP_YSIZE,40);
//       ObjectSetInteger(0,"P2edit",OBJPROP_SELECTABLE,false);
//       ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
//       ObjectSetString (0,"P2edit",OBJPROP_TEXT,sPBB);
//       ObjectSetInteger(0,"P2edit",OBJPROP_FONTSIZE,16);
//       ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrGray);
//       ObjectSetInteger(0,"P2edit",OBJPROP_ALIGN,ALIGN_CENTER);
//       ObjectSetInteger(0,"P2edit",OBJPROP_READONLY,false);
//    } 
//   
//   if(PBB==0) PBB=(int)StringToInteger(sPBB);
// 
//   if(PBB<5) period_ma1=5; else  period_ma1=PBB;
//   if(PBB>300) period_ma1=300; else  period_ma1=PBB;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

   ArraySetAsSeries(close,true);//--- Установка массивов буферов как таймсерий
//--- Проверка количества доступных баров
   if(rates_total<fmax(period_max,4)) return 0;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferMA1,EMPTY_VALUE);
     }

//--- Подготовка данных
   int count=(limit>0 ? rates_total : 1),copied=0;
   copied=CopyBuffer(handle_ma1,0,0,count,BufferMA1);
   if(copied!=count) return 0;

//Comment("ошибка = ");

//--- возвращаемое значение prev_calculated для следующего вызова
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|            deinit                                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   int i;
   int obj_total=ObjectsTotal(0,0,-1);
   for(i=obj_total-1;i>=0;i--)
     {
      sn=ObjectName(0,i,0,-1);
      if(ObjectFind(0,sn)==0)
        {
         if(StringFind(sn,"P2edit",0)==0) ObjectDelete(0,sn);
        }
     }

   Comment("");
   return;
  }
//+------------------------------------------------------------------+
 
Vladimir Pastushak:

Respeto por el esfuerzo.

Con éxito.

Agradecido. Francamente.

 
Vladimir Pastushak:

¿Estoy en lo cierto al suponer que después de un pase los agentes duermen y esperan a que los restantes agentes ocupados terminen su trabajo?


Sí. A veces este tiempo de inactividad de los núcleos libres lleva mucho tiempo cuando se optimiza sobre ticks reales.

¿Tal vez los desarrolladores puedan resolver este problema?

 

No hay manera de obtener un enlace a la entrada en el feed. Por ejemplo, para dejarlo en sus marcadores.

 
fxsaber:

No hay manera de obtener un enlace a la entrada en el feed. Por ejemplo, para dejarlo en sus marcadores.

https://www.mql5.com/ru/users/fxsaber#profileMessage_6131695 ¿es así?
 

Sí, pero no veo una forma habitual de conseguir el enlace.

 
   long a=132;
   if(a>-9223372036854775808)
     {Print("а прошла проверку на  > INT64_MIN");}
   else{Print("а НЕ прошла проверку на  > INT64_MIN");}

   if(a<-9223372036854775808)
     {Print("а прошла проверку на < INT64_MIN");}
   else{Print("а НЕ прошла проверку на < INT64_MIN");}

   if(a!=-9223372036854775808)
     {Print("а прошла проверку на != INT64_MIN");}
   else{Print("а НЕ прошла проверку на != INT64_MIN");}

Resultado

2019.05.14 11:49:13.574 check (EURUSD,M5)       а НЕ прошла проверку на  > INT64_MIN
2019.05.14 11:49:13.574 check (EURUSD,M5)       а прошла проверку на < INT64_MIN
2019.05.14 11:49:13.574 check (EURUSD,M5)       а прошла проверку на != INT64_MIN


¿Es esto exactamente como debería ser?

 

Hola a todos.

En las últimas compilaciones ha empezado a aparecer este error:

2019.05.14 13:03:50.526 EURUSD: history data load error
2019.05.14 13:03:50.528 EURUSD,M5: history cache allocated for 101454 bars and contains 74274 bars from 2018.01.02 09:00 to 2018.12.31 20:55
2019.05.14 13:03:50.528 EURUSD,M5: history begins from 2018.01.02 09:00
2019.05.14 13:03:50.533 history error 9 in undefined function
2019.05.14 13:03:50.533 stopped on 0% of testing interval with error '03 EURUSD'


y sigue apareciendo cada dos por tres.

¿Qué significa?

 
Alexey Klenov:

Resultado

¿Es esto exactamente como debería ser?

Si se profundiza, hay varias contradicciones de este tipo:
void OnStart()
{
        Print( typename( LONG_MIN             ),             LONG_MIN ); //(1)
        Print( typename( -9223372036854775808 ), -9223372036854775808 ); //(2)
        Print( typename( -9223372036854775807 ), -9223372036854775807 ); //(3)

        Print( typename( INT_MIN              ),              INT_MIN ); //(4)
        Print( typename( -2147483648          ), -2147483648          ); //(5)
        Print( typename( -2147483647          ), -2147483647          ); //(6)
}

Resultado:

largo -9223372036854775808
ulong 9223372036854775808
largo -9223372036854775807

int -2147483648
largo-2147483648
int -2147483647

¿Cuál es la diferencia fundamental entre (1)(2)(3) y (4)(5)(6), respectivamente?