ChartPeriod

Retourne la période du graphique indiqué.

ENUM_TIMEFRAMES  ChartPeriod(
   long  chart_id=0      // identificateur du graphique
   );

Paramètres

chart_id=0

[in] L'identificateur du graphique. 0 signifie le graphique courant.

Valeur de Retour

Une valeur du type ENUM_TIMEFRAMES. Si le graphique n'existe pas, retourne 0.

Exemple :

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- récupère la période actuelle du graphique et affiche la valeur obtenue dans le journal
   ENUM_TIMEFRAMES period=ChartPeriod();
   Print("Current chart period: "EnumToString(period));
   
//--- prends l'identifiant du graphique existante (dans cas cas, l'actuel)
   long chart_id=ChartID();
   period=ChartPeriod(chart_id);
   PrintFormat("Chart period with ID %I64d: %s"chart_idEnumToString(period));
   
//--- définit un identifiant de graphique aléatoire
   period=ChartPeriod(1234567890);
   if(period==0)
      Print("The chart with ID 1234567890 does not exist");
   else
      Print("Chart period with ID 1234567890: "EnumToString(period));
   /*
   résultat :
   Current chart periodPERIOD_M15
   Chart period with ID 133510090240498505PERIOD_M15
   The chart with ID 1234567890 does not exist
   */
  }