//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 経済指標カレンダーから国のリストを取得する
MqlCalendarCountry countries[];
int count=CalendarCountries(countries);
//--- 結果を確認する
if(count==0)
PrintFormat("CalendarCountries() returned 0!Error %d",GetLastError());
//--- 2国以上が存在する場合
if(count>=2)
{
MqlCalendarCountry country;
//--- IDによって国の説明を取得する
if(CalendarCountryById(countries[1].id, country))
{
//--- 国の説明を準備する
string descr="id = "+IntegerToString(country.id)+"\n";
descr+=("name = " + country.name+"\n");
descr+=("code = " + country.code+"\n");
descr+=("currency = " + country.currency+"\n");
descr+=("currency_symbol = " + country.currency_symbol+"\n");
descr+=("url_name = " + country.url_name);
//--- 国の説明を表示する
Print(descr);
}
else
Print("CalendarCountryById() failed. Error ",GetLastError());
}
//---
}
/*
結果:
id = 999
name = European Union
code = EU
currency = EUR
currency_symbol = €
url_name = european-union
*/
|