Sólo se muestra el último objeto string del gráfico

 

Hola a todos, espero alguien me pueda resolver esta duda. Gracias de antemano.

Mi EA dibuja un texto en la gráfica, pero sólo se visualiza el último, los anterior

bool TextCreate(const long              chart_ID=0,               // chart's ID
                const string            name="Text",              // object name
                const int               sub_window=0,             // subwindow index
                datetime                time=0,                   // anchor point time
                double                  price=0,                  // anchor point price
                const string            text="Text",              // the text itself
                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
  {
//-

   ResetLastError();
//--- create Text object
   if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price))//ok
     {
      Print(__FUNCTION__,
            ": failed to create \"Text\" object! Error code = ",GetLastError());
      return(false);
     }
//--- set the text
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);//ok
//--- set text font
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);//ok
//--- set font size
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);//ok
//--- set the slope angle of the text
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);//ok
//--- set anchor type
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);//ok
//--- set color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);//ok
//--- 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 object 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);
  } 
  
void Dibujar_Vela(int ind)     //se usa cada New Bar
   {       
         // Dibujar las velas que coinciden
         string var_1;
         string var_2;
         if(ArraySize(seniales_detected_w)>0)
            {
               
               //Dibujar las señales weakness correspondiente
               for(int i=0; i<ArraySize(seniales_detected_w); i++)
                  {
                     //TextCreat crea el objeto de texto y lo modifica
                     //0 significa la grafica actual
                     //StringConcatenate(Time[ind],"w",seniales_detected_w[i]) es el nombre del objeto
                     //Time[ind es para indicar donde se posiciona eje de tiempo,        
                     //LOw[]-.. ubicacion con eje de precio
                     //seniales_detected_w[i] será el texto a insertar en el objeto
                     
                      TextCreate(0,StringConcatenate(var_1,iTime(NULL,PERIOD_CURRENT,ind)," w ",seniales_detected_w[i]),0,iTime(NULL,PERIOD_CURRENT,ind),iLow(NULL,PERIOD_CURRENT,ind)-(2*atr[0])-(i*atr[0]),seniales_detected_w[i],"Arial",10,255,90);         
                  }
            }
            
         if(ArraySize(seniales_detected_s)>0)
            {
               //Dibujar las señales weakness correspondiente
               for(int i=0; i<ArraySize(seniales_detected_s); i++)
                  TextCreate(0,StringConcatenate(var_2,iTime(NULL,PERIOD_CURRENT,ind)," s ",seniales_detected_s[i]),0,iTime(NULL,PERIOD_CURRENT,ind),iHigh(NULL,PERIOD_CURRENT,ind)+(2*atr[0])+(i*atr[0]),seniales_detected_s[i],"Arial",10,Green,90);         
            }  
   }   


es desaparecen de la gráfica. Esto funciona bien con la programación en mql4, pero la recodificar a mql5, esta parte de código parece que debería funcionar igual pero tengo este problema. Adjunto código y una fotografía de la gráfica, donde se ve junto al cursor el objeto dibujado (EF) pero no ninguno otro anterior.

Archivos adjuntos:
 
Por aclarar mejor mi problema: en MT5 yo quiero que se muestren todos los objetos que se han ido creando, igual que sucede en MT4, pero en MT5 el objeto desaparece cuando se crea el siguiente, con lo que sólo se ve el último objeto en la gráfica. En la lista de objetos sólo figura el último. Gracias.
 


Coloca el codigo en donde muestres como estas usando o llamando la funcion "Dibujar_Vela"


Saludos!!!

 
Miguel Antonio Rojas Martinez:


Coloca el codigo en donde muestres como estas usando o llamando la funcion "Dibujar_Vela"


Saludos!!!

Hola Miguel Antonio,

La llamada a la función "Dibujar_Vela" está en OnTick de la siguiente manera:

Dibujar_Vela(2); 

El código en OnTick en este EA es muy extenso pero no aporta nada interesante sobre lo que estamos hablando. La función Dibujar_Vela funciona, lo que no sé es porque en MT5 los textos dibujados no permanecen, sino que desaparecen. En MT4 sí que permanecen.

 
 //Dibujar las señales weakness correspondiente
               for(int i=0; i<ArraySize(seniales_detected_w); i++)
                  {
                     //TextCreat crea el objeto de texto y lo modifica
                     //0 significa la grafica actual
                     //StringConcatenate(Time[ind],"w",seniales_detected_w[i]) es el nombre del objeto
                     //Time[ind es para indicar donde se posiciona eje de tiempo,        
                     //LOw[]-.. ubicacion con eje de precio
                     //seniales_detected_w[i] será el texto a insertar en el objeto
                     
                     StringConcatenate(var_1,iTime(NULL,PERIOD_CURRENT,ind);
                     
                     TextCreate(0,var_1," w ",seniales_detected_w[i]),0,iTime(NULL,PERIOD_CURRENT,ind),iLow(NULL,PERIOD_CURRENT,ind)-(2*atr[0])-(i*atr[0]),seniales_detected_w[i],"Arial",10,255,90);         
                  }


Prueba haciendo este pequeño cambio

Saludos!!!!

 
Miguel Angel eres un crack!! muchas gracias... siguiendo tu consejo he solucionado el problema!!
 
Miguel Antonio muchas gracias... sabes mucho!!