//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- récupère le symbole actuel du graphique et affiche la valeur obtenue dans le journal
string chart_symbol = ChartSymbol();
Print("Current chart symbol: ", chart_symbol);
//--- prends l'identifiant du graphique existante (dans cas cas, l'actuel)
long chart_id=ChartID();
chart_symbol=ChartSymbol(chart_id);
PrintFormat("Chart symbol with ID %I64d: %s", chart_id, chart_symbol);
//--- définit un identifiant de graphique aléatoire lors de la réception d'un symbole
chart_symbol = ChartSymbol(1234567890);
if(chart_symbol=="")
Print("The chart with ID 1234567890 does not exist");
else
Print("Chart symbol with ID 1234567890: ", chart_symbol);
/*
résultat :
Current chart symbol: GBPUSD
Chart symbol with ID 132966427583395104: GBPUSD
The chart with ID 1234567890 does not exist
*/
}
|