ChartClose

Cierra el gráfico especificado.

bool  ChartClose(
   long  chart_id=0      // identificador del gráfico
   );

Parámetros

chart_id=0

[in]  Identificador del gráfico. 0 significa el gráfico actual.

Valor devuelto

Devuelve true en caso de éxito, de lo contrario devuelve false.

Ejemplo:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- abrirmos un nuevo gráfico con el símbolo y periodo como el gráfico actual
   long chart_id=ChartOpen(_Symbol_Period);
   if(chart_id==0)
     {
      Print("ChartOpen() failed. Error "GetLastError());
      return;
     }
 
//--- imprimimos en el registro los parámetros del gráfico abierto
   PrintFormat("A new chart of the %s symbol has been opened with a period of %s and ChartID %I64u",
               _SymbolStringSubstr(EnumToString(_Period), 7), chart_id);
 
//--- esperamos dos segundos y cerramos el gráfico recién abierto
   PrintFormat("Waiting 3 seconds before closing a newly opened chart with ID %I64d ..."chart_id);
   Sleep(3000);
   ResetLastError();
   if(!ChartClose(chart_id))
     {
      Print("ChartClose() failed. Error "GetLastError());
      return;
     }
 
//--- imprimimos un mensaje en el registro sobre el cierre exitoso del gráfico
   PrintFormat("The chart with ID %I64d was successfully closed"chart_id);
   /*
   resultado:
   A new chart of the GBPUSD symbol has been opened with a period of M1 and ChartID 133346697706632016
   Waiting 3 seconds before closing a newly opened chart with ID 133346697706632016 ...
   The chart with ID 133346697706632016 was successfully closed
   */
  }