//+------------------------------------------------------------------+
//| 스크립트 프로그램 시작 함수 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 현재 차트와 동일한 심볼 및 기간을 사용하여 새 차트를 엽니다.one
long chart_id=ChartOpen(_Symbol, _Period);
if(chart_id==0)
{
Print("ChartOpen() failed. Error ", GetLastError());
return;
}
//--- 저널에서 오픈 차트 매개변수를 인쇄합니다.
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);
//--- 2초를 기다리고 이후 새로 열린 차트를 닫습니다
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;
}
//--- 저널에 성공적인 차트 종료 메시지를 인쇄합니다.
PrintFormat("The chart with ID %I64d was successfully closed", chart_id);
/*
결과:
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
*/
}
|