#define SYMBOL "GBPUSD"
#define PERIOD PERIOD_H1
//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 現在のチャートID、銘柄、期間を取得する
long chart_id= ChartID();
string symbol = Symbol();
ENUM_TIMEFRAMES period = Period();
//--- 現在のチャートの銘柄と期間を SYMBOL と PERIOD で設定されたものに置き換えたことを操作ログ報告する
PrintFormat("Change the %s symbol and the %s period of the chart %I64u to %s %s",
symbol, TimeframeDescrioption(period), chart_id, SYMBOL, TimeframeDescrioption(PERIOD));
//--- チャートの銘柄と期間を変更する
ChartSetSymbolPeriod(chart_id, SYMBOL, PERIOD);
/*
結果:
Change the EURUSD symbol and the M1 period of the chart 133246248352168440 to GBPUSD H1
*/
}
//+------------------------------------------------------------------+
//| チャートの期間の説明を返す |
//+------------------------------------------------------------------+
string TimeframeDescrioption(const ENUM_TIMEFRAMES timeframe)
{
return(StringSubstr(EnumToString(timeframe), 7));
}
|