ChartPeriod

Retorna o periodo do gráfico especificado.

ENUM_TIMEFRAMES  ChartPeriod(
   long  chart_id=0      // ID gráfico
   );

Parâmetros

chart_id=0

[in]  ID Gráfico. Representa o gráfico atual.

Valor retornado

A função retorna um valor ENUM_TIMEFRAMES. Se gráfico não existir retorna 0 (zero).

Exemplo:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- obtemos o período do gráfico atual e enviamos o valor obtido para o log
   ENUM_TIMEFRAMES period=ChartPeriod();
   Print("Current chart period: "EnumToString(period));
   
//--- recebemos o identificador do gráfico existente (nesse caso, o gráfico atual)
   long chart_id=ChartID();
   period=ChartPeriod(chart_id);
   PrintFormat("Chart period with ID %I64d: %s"chart_idEnumToString(period));
   
//--- definimos um identificador aleatório para o gráfico
   period=ChartPeriod(1234567890);
   if(period==0)
      Print("The chart with ID 1234567890 does not exist");
   else
      Print("Chart period with ID 1234567890: "EnumToString(period));
   /*
   resultado:
   Current chart periodPERIOD_M15
   Chart period with ID 133510090240498505PERIOD_M15
   The chart with ID 1234567890 does not exist
   */
  }