Discusión sobre el artículo "Traslado de MQL4 a MQL5" - página 10

 
-Aleks-:

No entiendo cómo utilizar la función

El compilador advierte

'OBJPROP_TIME1' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2891 12
'OBJPROP_TIME1' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2891 12
'OBJPROP_PRICE1' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2893 12
'OBJPROP_PRICE1' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2893 12
'OBJPROP_TIME2' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2895 12
'OBJPROP_TIME2' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2895 12
'OBJPROP_PRICE2' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2897 12
'OBJPROP_PRICE2' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2897 12
'OBJPROP_TIME3' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2899 12
'OBJPROP_TIME3' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2899 12
'OBJPROP_PRICE3' - identificador no declarado TZ_Sky_and_Ground_V_04.mq5 2901 12
'OBJPROP_PRICE3' - expresión constante requerida TZ_Sky_and_Ground_V_04.mq5 2901 12

Cambia ObjectSetInteger(...) por ObjectSetMQL4(...) en las líneas donde se produce el error.

En general, es más fácil de reescribir, es muy rápido cambiar allí, literalmente 2 minutos de tiempo

 
Vitaly Muzichenko:

Cambia ObjectSetInteger(...) por ObjectSetMQL4(...) en las líneas donde se produce el error.

En general, es más fácil de reescribir, es muy rápido cambiarlo allí, literalmente 2 minutos de tiempo

No entiendo o no funciona.

Yo tenía una función de este tipo


//+------------------------------------------------------------------+
//|Función para mostrar información en pantalla|
//+------------------------------------------------------------------+
void Label(string _name,int _window,int _x,int _y,string _text,int _font,color _color,int corner)
  {
   ObjectDelete(0,_name);
   ObjectCreate(0,_name,OBJ_LABEL,_window,0,0);
   ObjectSet(_name,OBJPROP_CORNER,corner);
   ObjectSet(_name,OBJPROP_XDISTANCE,_x);
   ObjectSet(_name,OBJPROP_YDISTANCE,_y);
   ObjectSetText(_name,_text,_font,"Arial",_color);
  }

Para que funcione en MQL5, he añadido desde el artículo


  bool ObjectSetText(string name, string text, int font_size,string font="", color text_color=CLR_NONE)
  {
   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);
   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);
   if(StringLen(text)>0 && font_size>0)
     {
      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true
         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)
        {
         if((StringLen(font)>0)
            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)
            return(false);
         if(text_color>-1
            && ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)
            return(false);
         return(true);
        }
      return(false);
     }
   return(false);
  }
  
bool ObjectSet(string name, int index, double value)
  {
   switch(index)
     {
      case OBJPROP_TIME1:
         ObjectSetInteger(0,name,OBJPROP_TIME,(int)value);return(true);
      case OBJPROP_PRICE1:
         ObjectSetDouble(0,name,OBJPROP_PRICE,value);return(true);
      case OBJPROP_TIME2:
         ObjectSetInteger(0,name,OBJPROP_TIME,1,(int)value);return(true);
      case OBJPROP_PRICE2:
         ObjectSetDouble(0,name,OBJPROP_PRICE,1,value);return(true);
      case OBJPROP_TIME3:
         ObjectSetInteger(0,name,OBJPROP_TIME,2,(int)value);return(true);
      case OBJPROP_PRICE3:
         ObjectSetDouble(0,name,OBJPROP_PRICE,2,value);return(true);
      case OBJPROP_COLOR:
         ObjectSetInteger(0,name,OBJPROP_COLOR,(int)value);return(true);
      case OBJPROP_STYLE:
         ObjectSetInteger(0,name,OBJPROP_STYLE,(int)value);return(true);
      case OBJPROP_WIDTH:
         ObjectSetInteger(0,name,OBJPROP_WIDTH,(int)value);return(true);
      case OBJPROP_BACK:
         ObjectSetInteger(0,name,OBJPROP_BACK,(int)value);return(true);
      case OBJPROP_RAY:
         ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,(int)value);return(true);
      case OBJPROP_ELLIPSE:
         ObjectSetInteger(0,name,OBJPROP_ELLIPSE,(int)value);return(true);
      case OBJPROP_SCALE:
         ObjectSetDouble(0,name,OBJPROP_SCALE,value);return(true);
      case OBJPROP_ANGLE:
         ObjectSetDouble(0,name,OBJPROP_ANGLE,value);return(true);
      case OBJPROP_ARROWCODE:
         ObjectSetInteger(0,name,OBJPROP_ARROWCODE,(int)value);return(true);
      case OBJPROP_TIMEFRAMES:
         ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,(int)value);return(true);
      case OBJPROP_DEVIATION:
         ObjectSetDouble(0,name,OBJPROP_DEVIATION,value);return(true);
      case OBJPROP_FONTSIZE:
         ObjectSetInteger(0,name,OBJPROP_FONTSIZE,(int)value);return(true);
      case OBJPROP_CORNER:
         ObjectSetInteger(0,name,OBJPROP_CORNER,(int)value);return(true);
      case OBJPROP_XDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,(int)value);return(true);
      case OBJPROP_YDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,(int)value);return(true);
      case OBJPROP_FIBOLEVELS:
         ObjectSetInteger(0,name,OBJPROP_LEVELS,(int)value);return(true);
      case OBJPROP_LEVELCOLOR:
         ObjectSetInteger(0,name,OBJPROP_LEVELCOLOR,(int)value);return(true);
      case OBJPROP_LEVELSTYLE:
         ObjectSetInteger(0,name,OBJPROP_LEVELSTYLE,(int)value);return(true);
      case OBJPROP_LEVELWIDTH:
         ObjectSetInteger(0,name,OBJPROP_LEVELWIDTH,(int)value);return(true);

      default: return(false);
     }
   return(false);
  }
Obtuve los errores descritos arriba.
 
-Aleks-:

No lo entiendo o no funciona.

Tenía esta función


Para que funcionara en MQL5, la agregue desde el articulo.


Y me salieron los errores antes descritos.

Este tipo de construcciones deberían haberse tirado por el retrete allá por 2013.

   ObjectSet(_name,OBJPROP_CORNER,corner);
   ObjectSet(_name,OBJPROP_XDISTANCE,_x);
   ObjectSet(_name,OBJPROP_YDISTANCE,_y);
   ObjectSetText(_name,_text,_font,"Arial",_color);


Usar:

ObjectSetDouble(...)
ObjectSetInteger(...)
 
Vitaly Muzichenko:

Este es el tipo de diseños que deberían haberse tirado por el retrete allá por 2013

Úsalo:

Gracias. Entendí que en mi caso necesito poner ObjectSetInteger por todos lados .

 
-Aleks-:

Gracias. Entiendo que en mi caso tengo que poner ObjectSetInteger en todas partes .

Por supuesto.

La ayuda describe todo perfectamente bien, donde se necesita Integer y donde se necesita Dooble

 
Vitaly Muzichenko:

Absolutamente.

La ayuda describe todo perfectamente bien, donde se necesita Integer y donde se necesita Dooble

Yo estaba un poco confundido con la ayuda porque no sabía mucho acerca de trabajar con objetos antes y tomé prestada la función....

 
-Aleks-:

Yo era estúpido con la ayuda - como yo no sabía mucho acerca de cómo trabajar con objetos antes, pero me prestó la función....

Tomar prestado de las nuevas ramas y asesores. No tome prestado de las ramas de 2007)

 
Vitaly Muzichenko:

Pide prestado a las nuevas sucursales y asesores. No tome prestado de las sucursales de 2007)

Este préstamo fue en 2013 - sólo se mueve de un lugar a otro ...

 

Por favor, indique cómo trabajar con iFractalsMQL4

   for (int i=0; i<np; i++) //ciclo de caracteres
   {
     m_symbols[i].Refresh();
   
               for (int ii=2;ii<=3;ii++)   //ciclo al primer fractal
               {
                  double dF=0;
                  int TMODE=1;
                  dF = iFractalsMQL4(Pairs[i],PERIOD_D1,TMODE,ii);
                  Print("i  ",i,"  ii  ",ii,"  Pairs[i] ",Pairs[i],"  TMODE  ",TMODE," dF ",dF);
               }
   }

Resultado:

2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 0 ii 2 Pairs[i] AUDCAD_i TMODE 1 dF 1.00731
2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 0 ii 3 Pares[i] AUDCAD_i TMODE 1 dF 1.797693134862316e+308
2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 1 ii 2 Pairs[i] AUDCHF_i TMODE 1 dF 1.797693134862316e+308 ...

Es decir, iFractalsMQL4 funciona en la primera llamada, pero luego no.

CSymbolInfo m_symbols[]; // objeto de información de símbolos
y

m_symbols[i].Refresh();
no son correctos. ¿Qué hay que hacer?

 

Gracias,

Su arduo trabajo en este artículo es muy útil :)