//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 現在のチャート期間を取得し、取得した値を操作ログに表示する
ENUM_TIMEFRAMES period=ChartPeriod();
Print("Current chart period: ", EnumToString(period));
//--- 既存の(この場合は現在の)チャートIDを取得する
long chart_id=ChartID();
period=ChartPeriod(chart_id);
PrintFormat("Chart period with ID %I64d: %s", chart_id, EnumToString(period));
//--- ランダムなチャートIDを設定する
period=ChartPeriod(1234567890);
if(period==0)
Print("The chart with ID 1234567890 does not exist");
else
Print("Chart period with ID 1234567890: ", EnumToString(period));
/*
結果:
Current chart period: PERIOD_M15
Chart period with ID 133510090240498505: PERIOD_M15
The chart with ID 1234567890 does not exist
*/
}
|