ChartClose

指定されたチャートを閉じます。

bool  ChartClose(
  long  chart_id=0      // チャート識別子
  );

パラメータ

chart_id=0

[in]  チャート識別子。( 0 は現在のチャート)

戻り値

成功の場合は true、それ以外の場合は false

例:

//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数                                              |
//+------------------------------------------------------------------+
void OnStart()
 {
//--- 現在の銘柄と期間で新しいチャートを開く
  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
  */
 }