asesor experto - preguntas varias - página 6

 

Estoy tratando de hacer botón de reinicio de lote, pero tengo que conseguir muchomejor resultado que esto, pero no puedo.
( No me gustan todos mis ea's e indicadores Botón objetos porque todos ellos muy feo como este. )

Necesito dos cosas de ustedes que pueden ayudar y me da un buen consejo, por favor, realmente necesito su ayuda.
He pasado mucho tiempo, y no puedo averiguar cuál es el problema con mi código.

Gracias de antemano.

//--- segunda vez editado - mientras escribo este comentario tal vez estaba durmiendo...

ObjectCreate     ( 0, "button lot reset", OBJ_BUTTON           , 0, 0, 0           );
ObjectSetString  ( 0, "button lot reset", OBJPROP_TEXT         , "x"               );
ObjectSetString  ( 0, "button lot reset", OBJPROP_FONT         , "Verdana"         );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_FONTSIZE     , 14                );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_XDISTANCE    , 16                );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_YDISTANCE    , 16                );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_XSIZE        , 18                );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_YSIZE        , 18                );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_CORNER       , CORNER_LEFT_UPPER );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_COLOR        , White             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BGCOLOR      , Black             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BORDER_COLOR , Black             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_STATE        , false             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BACK         , false             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTABLE   , false             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTED     , false             );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_HIDDEN       , true              );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_ZORDER       , true              );
 
  1. Si está oculto, ¿cómo se puede ver y hacer clic en él?
  2. ZORDER no es booleano, es un int 0...
 
//+------------------------------------------------------------------+
//| Create the button                                                |
//+------------------------------------------------------------------+
bool ButtonCreate(const long              chart_ID=0,               // chart's ID
                  const string            name="Button",            // button name
                  const int               sub_window=0,             // subwindow index
                  const int               x=0,                      // X coordinate
                  const int               y=0,                      // Y coordinate
                  const int               width=50,                 // button width
                  const int               height=18,                // button height
                  const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring
                  const string            text="Button",            // text
                  const string            font="Arial",             // font
                  const int               font_size=10,             // font size
                  const color             clr=clrBlack,             // text color
                  const color             back_clr=C'236,233,216',  // background color
                  const color             border_clr=clrNONE,       // border color
                  const bool              state=false,              // pressed/released
                  const bool              back=false,               // in the background
                  const bool              selection=false,          // highlight to move
                  const bool              hidden=true,              // hidden in the object list
                  const long              z_order=0)                // priority for mouse click
  {
//--- reset the error value
   ResetLastError();
//--- create the button
   if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": failed to create the button! Error code = ",GetLastError());
      return(false);
     }
//--- set button coordinates
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- set button size
   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);
//--- set the chart's corner, relative to which point coordinates are defined
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
//--- set the text
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- set text font
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- set font size
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- set text color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set background color
   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);
//--- set border color
   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- set button state
   ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);
//--- enable (true) or disable (false) the mode of moving the button by mouse
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution
   return(true);
  }
//+------------------------------------------------------------------+

Por favor, usted puede utilizar la función de la documentación 'como es' para crear los botones sólo tiene que añadir en la parte inferior de su código y se puede llamar a la función y pasar los parámetros.

Así que entonces usted puede simplemente llamar:

ButtonCreate(...

También

whroeder1:
  1. Si está oculto, ¿cómo se puede ver y hacer clic en él?
  2. ZORDER no es booleano, es un int 0...
Oculto es simplemente oculto en la lista de objetos.
 
whroeder1:
  1. Si está oculto, ¿cómo se puede ver y hacer clic en él?
  2. ZORDER no es booleano, es un int 0...

Gracias lo he arreglado, solo que fue un error.
--------------------------------------------

Marco vd Heijden:

Por favor, puedes usar la función de la documentación 'tal cual' para crear los botones sólo tienes que añadirla al final de tu código y puedes llamar a la función y pasar los parámetros.

Así que entonces puedes llamar:

ButtonCreate(...)

Gracias Marco que me ayudará mucho, y los códigos de mi EA parece limpiado.
También tengo que preguntar sobre el código de abajo, ¿qué es, ¿cómo es el trabajo? ( incluso he leído sobre eso pero no entiendo más claramente )

Por favor, explica un poco más, gracias de antemano.

ObjectSetString ( 0, name, OBJPROP_TOOLTIP , tip );

----------------------------------------

También necesito usar void en vez de bool como en el código de abajo así que¿cuál es bueno?

bool ButtonCreate(...)

// or

void ButtonCreate(...)
 

La función devuelve true o false dependiendo de si la creación del botón fue exitosa o no, así que depende de usted si quiere verificar que el botón fue efectivamente creado.

Para la segunda pregunta, el tooltip es lo que se hace visible cuando se pasa el ratón por encima del objeto en el gráfico.

La forma en que estás trabajando ahora tiene limitaciones.

Si quieres ampliarlo lee los siguientes artículos:

https://www.mql5.com/en/search#!keyword=graphical%20interfaces&module=mql5_module_articles

 
Marco vd Heijden:

La función devuelve true o false dependiendo de si la creación del botón fue exitosa o no, así que depende de usted si quiere verificar que el botón fue efectivamente creado.

Para la segunda pregunta, el tooltip es lo que se hace visible cuando se pasa el ratón por encima del objeto en el gráfico.

La forma en que estás trabajando ahora tiene limitaciones.

Si quieres ampliarlo por favor lee los siguientes artículos:

https://www.mql5.com/en/search#!keyword=graphical%20interfaces&module=mql5_module_articles

Muchas gracias.
WOW, tío vas a ser mi hombre, Sr. Marco.

( desde tu primer comentario - me ayudaste mucho - siempre tratas de entender mis inquietudes - una vez más enormes gracias )

 
Bueno, sólo les señalo estos artículos y debemos estar muy agradecidos a los autores que los escribieron y también los tradujeron.
 

Necesito utilizar el formato de archivo .PNG en el código de mi EA, para el icono de LotSize.
Pero sólo he encontrado el formato de archivo . BMP, así que ¿alguien puede ayudarme / aconsejarme?

Si cualquier comentario podría rápidamente mucho aprecio, sólo estoy prisa un poco más.
Gracias de antemano.

 

Intento que si el tamaño del lote es mejor que el valor del lote, el estado sea verdadero y si no, falso.
( cuando hago click en el objeto 'Reset' entonces se convierte en 'state false' y después de aumentar el tamaño del lote el estado no se convierte en verdadero )

¿El código de abajo es incorrecto?

//|     Lot Reset
if ( sparam == _namelotRset )
{
    if ( _lotSize > _lotValue )
    {
        ObjectSetInteger( 0, sparam, OBJPROP_STATE, true );
    }   //---if Close
    else
    {
        ObjectSetInteger( 0, sparam, OBJPROP_STATE, false );
    }   //---if Close
    _lotSize = _lotValue * _lotMin;

    _infoUpdate();
    return;
}   //---if Close

Gracias.

//--- segunda vez editado

Trato de hacer girar'ON OFF' con el siguiente código.

ObjectSetString( chart_ID, name, OBJPROP_BMPFILE, on_off, file )
 

Consulte:

https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_bitmap

Para el tema del mapa de bits.

Y para el otro tema se puede empalmar en partes separadas para establecer el estado fuera de sparam.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_BITMAP
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_BITMAP
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_BITMAP - Reference on algorithmic/automated trading language for MetaTrader 5
Razón de la queja: