//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- ouvre un nouveau graphique avec le même symbole et la même période que le graphique actuel
long chart_id=ChartOpen(_Symbol, _Period);
if(chart_id==0)
{
Print("ChartOpen() failed. Error ", GetLastError());
return;
}
//--- écrit dans le journal les paramètres du graphique ouvert
PrintFormat("A new chart of the %s symbol has been opened with a period of %s and ChartID %I64u",
_Symbol, StringSubstr(EnumToString(_Period), 7), chart_id);
//--- attends 2 secondes et ferme le nouveau graphique
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;
}
//--- écrit dans le journal un message de fermeture réussie du graphique
PrintFormat("The chart with ID %I64d was successfully closed", chart_id);
/*
résultat :
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
*/
}
|