Mi enfoque. El núcleo es el motor. - página 95

 
Реter Konow:

Ya se han arreglado los sindicatos también.

No he llegado hasta el final.

Eso no es correcto:

Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",u.Uint,width,height))Print("Failed to read resource!  ",GetLastError());
   //-----------------------------
   Message = CharArrayToString(u.Char);
   //-----------------------------
   Print(Message);

Sí:

Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",u.Uint,width,height))Print("Failed to read resource!  ",GetLastError());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print(DoubleToString(bid));

¿Y cuál es el descuido en el código? Tiene estructuras Char_Uint diferentes para el destinatario y el remitente.

 
Vasiliy Sokolov:

No está exactamente calculado hasta el final.

Eso no es correcto:

Sí:

¿Y cuál es el descuido en el código? Tiene estructuras Char_Uint diferentes para el destinatario y el remitente.

Gracias, Vasily. No sabía que era necesario. Aunque también he probado la variante en la que las estructuras son idénticas.

De todos modos, el resultado de la salida no es el que quiero. Aquí está el código:

//+------------------------------------------------------------------+
//|                                                    Tester EA.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar   Char[8];
   uint    Uint[2];  
   double  Double; 
  };
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //----------------------------------------------
   if(!ObjectCreate(0,"Resource",OBJ_BITMAP_LABEL,0,0,0))Print("Object is not created!  ",GetLastError());
   else Print("Object created!");
   //-------------------------------
   if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"::Resource"))Print("BMPFILE is not created!");
   else Print("BMPFILE created!");
   //----------------------------------------------
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //---------------------------
   Char_Uint u;
   //---------------------------
   u.Double = Bid;
   //---------------------------
   if(!ResourceCreate("::Resource",u.Uint,2,1,0,0,0,COLOR_FORMAT_XRGB_NOALPHA))Print("Resource is not created!");
   //---------------------------   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+

Y el destinatario:

//+------------------------------------------------------------------+
//|                                              Resource reader.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar   Char[8];
   uint    Uint[2];  
   double  Double; 
  };
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   EventSetMillisecondTimer(5250); 
   
   if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"\\Experts\\Tester EA.ex4::Resource"))Print("Resource is not connected!");
   else Print("Resource connected!");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
  Char_Uint u;
   uint width,height;
   string Message; 
   //-----------------------------
   if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",u.Uint,width,height))Print("Failed to read resource!  ",GetLastError());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print(DoubleToString(bid,5));
  }
//+------------------------------------------------------------------+

Resultado:

2018.12.20 17:13:37.395 Resource reader GBPUSD,M5: 9223464270575144355.75808

Pero al menos no cambia. El valor es constante. (aunque debería cambiar a medida que cambia el valor de la oferta).

 
Реter Konow:

Pero al menos no cambia. El valor es constante. (aunque debería cambiar, ya que el valor de la oferta cambia).

Esto es muy extraño, porque tu ejemplo en mi ordenador funciona correctamente. Pruebe a hacer expertos y colóquelos simplemente en los dos gráficos.

 
Vasiliy Sokolov:

Esto es muy extraño, porque tu ejemplo en mi ordenador funciona correctamente. Pruebe ambos para hacer expertos y coloque sólo los dos gráficos.

Bien.

 

Aquí está el código del segundo EA en el segundo gráfico. El resultado es el mismo...

//+------------------------------------------------------------------+
//|                                                  Tester EA 2.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
union Char_Uint
  {
   uchar   Char[8];
   uint    Uint[2];  
   double  Double; 
  };
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
   if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"\\Experts\\Tester EA.ex4::Resource"))Print("Resource is not connected!");
   else Print("Resource connected!");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTick()
  {
  Char_Uint u;
   uint width,height;
   //-----------------------------
   if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",u.Uint,width,height))Print("Failed to read resource!  ",GetLastError());
   //-----------------------------
   double bid = u.Double;
   //-----------------------------
   Print(DoubleToString(bid,5));
  }
//+------------------------------------------------------------------+

No funciona como debería.

 
Aquí están mis fuentes por si acaso, compruébalas:
Archivos adjuntos:
 
Vasiliy Sokolov:
Aquí están mis fuentes por si acaso, compruébalas:

No. Es lo mismo. ¿Tal vez sea por los espacios en los nombres de EA? Los has descargado sin espacios, pero yo tengo espacios. Lo volveré a hacer.

 
Реter Konow:

No. Es lo mismo. ¿Tal vez sea por los espacios en los nombres de EA? Los has descargado sin espacios, pero yo tengo espacios. Lo volveré a hacer.

Pruébalo. El uso de espacios es altamente indeseable. Deshazte de este mal hábito.

 

Escribe:

2018.12.20 17:46:26.798 Tester_EA_2 EURCHF,H1: 0.00000
2018.12.20 17:46:34.801 Tester_EA_2 EURCHF,H1: Failed to read resource!  4100
4100 -

ERR_SOME_FILE_ERROR

 

Lo tengo. Error de lectura del archivo - sólo se olvidó de añadir un guión. Lo añadí y volví al resultado:

2018.12.20 17:55:24.590 Tester_EA_2 EURCHF,H1: 9223464270575144355.75808