Indicador Preguntas varias - página 11

 
Puedes ver mi código de ejemplo en este comentario #99
 

Oh ok ese código.

ObjectCreate() también necesita el ID del gráfico:

bool  ObjectCreate(
   long         chart_id,      // chart identifier
   string       name,          // object name
   ENUM_OBJECT  type,          // object type
   sub_window   nwin,          // window index
   datetime     time1,         // time of the first anchor point
   double       price1,        // price of the first anchor point
   ...
   datetime     timeN=0,       // time of the N-th anchor point
   double       priceN=0,      // price of the N-th anchor point
   ...
   datetime     time30=0,      // time of the 30th anchor point
   double       price30=0      // price of the 30th anchor point
   );

Como primer parámetro.

int OnInit()
  {
   Print("Outside");

   ObjectCreate("Object Outside",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Object Outside",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Object Outside",OBJPROP_YDISTANCE,20);
   ObjectSetString(0,"Object Outside",OBJPROP_TEXT,"Outside");

   if(DayOfWeek()==5)
     {
      Print("Inside");

      ObjectCreate("Object Inside",OBJ_LABEL,0,0,0);
      ObjectSetInteger(0,"Object Inside",OBJPROP_XDISTANCE,20);
      ObjectSetInteger(0,"Object Inside",OBJPROP_YDISTANCE,40);
      ObjectSetString(0,"Object Inside",OBJPROP_TEXT,"Inside");
     }
  }

Pero se empieza con el nombre del objeto.

También puedes especificar una esquina base/punto ancla.

Por favor, vea: https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_label

//+------------------------------------------------------------------+
//| Create a text label                                              |
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=0,               // chart's ID
                 const string            name="Label",             // label name
                 const int               sub_window=0,             // subwindow index
                 const int               x=0,                      // X coordinate
                 const int               y=0,                      // Y coordinate
                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring
                 const string            text="Label",             // text
                 const string            font="Arial",             // font
                 const int               font_size=10,             // font size
                 const color             clr=clrRed,               // color
                 const double            angle=0.0,                // text slope
                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor type
                 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 a text label
   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": failed to create text label! Error code = ",GetLastError());
      return(false);
     }
//--- set label coordinates
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- 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 the slope angle of the text
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- set anchor type
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the label 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);
  }
//+------------------------------------------------------------------+

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL - Reference on algorithmic/automated trading language for MetaTrader 5
 

Me preocupa que no haya podido explicar mi problema y quiero preguntar si lo has probado, por favor. Entonces usted puede saber cuál es mi problema con ese código.

Acabo de intentar como esto - 1. He añadido mi archivo de ejemplo a la tabla y luego cerrar MT4. 2. Abrir MT4 - entonces no veo mi objeto Inside Label.

Eso es lo que trato de encontrar la solución a mi problema : /


Tal vez voy a ser seguro el lunes.

( cuando pienso que esto es tan fácil paso mucho tiempo para que las cosas fáciles - cuando pienso que esto es tan difícil que los hice tan fácilmente ... - Casi todo lo que quiero hacer. primero trato de leer la documentación ... )

 

Lo he probado y aparecen dos objetos.

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
      Print("Outside");

   ObjectCreate(0,"Object Outside",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Object Outside",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Object Outside",OBJPROP_YDISTANCE,20);
   ObjectSetString(0,"Object Outside",OBJPROP_TEXT,"Outside");

   if(DayOfWeek()==5)
     {
      Print("Inside");

      ObjectCreate(0,"Object Inside",OBJ_LABEL,0,0,0);
      ObjectSetInteger(0,"Object Inside",OBJPROP_XDISTANCE,20);
      ObjectSetInteger(0,"Object Inside",OBJPROP_YDISTANCE,40);
      ObjectSetString(0,"Object Inside",OBJPROP_TEXT,"Inside");
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+


 

¡Genial!

Mira mi captura de pantalla, por favor.

hay un problema

Muchas gracias por su tiempo Sr. Marco

 

No me importa que parte del código me dé un resultado diferente en el indicador : /
Intento esa parte del código en mi archivo de indicador.

( He decidido que escribiré algún código en los archivos de los indicadores, pero no en mi archivo del Panel de Operaciones. )


2da vez editado

Ya he utilizado su método - ahora funciona sin problemas, espero que funcione.

Muchas gracias Sr. Marco


#Not Monday - Cerrado
 

#Refrescar - Abrir

Una vez que resuelvo mi este problema - mi indicador funciona bien en mi plataforma principal MT4 - pero yo uso 2 ª plataforma MT4 que es mi indicador necesita actualizar cuando inicio plataforma MT4.
No tengo ni idea de dónde viene ese problema... que pregunto algo exactamente sobre eso.

P: ¿Puede alguien decirme algo sobre esta extraña situación, por favor?

Gracias de antemano.

 

¿Quiere decir que se observa un comportamiento diferente entre dos plataformas?

¿Son de la misma construcción?

 
Marco vd Heijden:

¿Quiere decir que es testigo de un comportamiento diferente entre dos plataformas?

¿Son la misma build?

Sí, absolutamente diferente comportamiento...

También sí ambos 1065 Build

 

Tal vez haya encontrado de dónde vienen esos extraños problemas...

¿Qué secreto de la plantilla de carga?
Hay cosas místicas, que me está destruyendo en absoluto... que es realmente me hace loco en absoluto... - Ya he hecho grandes cosas para mi EA y el indicador de que nunca pasó mucho tiempo como yo estoy gastando algunas cuestiones de menor importancia...

¿Cómo? Muy sencillo.

Después de que decidí que no debería poner algunos scripts en los archivos de mi EA - entonces continuamente me enfrento a problemas menores que no puedo encontrar la solución en SEO. ( en realidad a veces encuentro fácilmente la solución a mis enormes problemas de EA en SEO - pero estos problemas menores. )

---

Puse este código simple en mi archivo de indicador de ejemplo.

int OnInit()
{
  Print( "This Year", Year() );
  return(INIT_SUCCEEDED);
}

Cuando intento cargar este archivo de ejemplo en mi gráfico. No funciona correctamente hasta que cambio el TimeFrame.
( es posible que ya me canse hoy )
( también se que puedo resolver este problema si pongo ese código en OnCalculate(...) - pero solo necesito poner ese código en OnInit() )

Por favor, sólo necesito una explicación más clara para este problema. Realmente lo necesito, porque algunos de mis indicadores tienen los mismos problemas irrelevantes. ( que si pongo esto en los archivos de mi EA funcionará correctamente )

Gracias de antemano.
Que tengáis un buen fin de semana.

Razón de la queja: