Indicators: Candle Grids

 

Candle Grids:

Draw a Rectangle on chart to plot custom grids based on points value on input

Candle Grids

Author: Rajesh Kumar Nait

 
great
 

Automatic translation was applied by a moderator. On the English forum, please write in English.

I see it's causing flickering.

I suggest the following changes:

//+------------------------------------------------------------------+
//| VARIABLES GLOBALES                                               |
//+------------------------------------------------------------------+
string rectangle_name = ""; // Nombre del rectángulo de referencia
bool rectangle_exists = false; // Bandera para controlar existencia del rectángulo



void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam) {
   
   // Evento: creación de objeto
   if(id == CHARTEVENT_OBJECT_CREATE) {
      // Verificar si es un rectángulo y no es de nuestro indicador
      if(ObjectGetInteger(0, sparam, OBJPROP_TYPE) == OBJ_RECTANGLE && 
         StringFind(sparam, prefix) == -1) {
         rectangle_name = sparam;
         rectangle_exists = true;
         DrawGrid();
      }
   }
   
   // Evento: arrastre de objeto
   if(id == CHARTEVENT_OBJECT_DRAG) {
      // Solo actualizar si el rectángulo de referencia está siendo arrastrado
      if(sparam == rectangle_name) {
         DrawGrid();
      }
   }
   
   // Evento: eliminación de objeto
   if(id == CHARTEVENT_OBJECT_DELETE) {
      // Si se elimina nuestro rectángulo de referencia
      if(sparam == rectangle_name) {
         ObjectsDeleteAll(0, prefix);
         rectangle_exists = false;
         rectangle_name = "";
      }
   }
}