CalendarCountryById
IDによって国の説明を取得します。
bool CalendarCountryById(
const long country_id,
MqlCalendarCountry& country
);
|
パラメータ
country_id
[in] Country ID (ISO 3166-1).
country
[out] 国の説明を受け取るためのMqlCalendarCountry型変数
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 5402 – ERR_CALENDAR_NO_DATA(無効な国)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
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
*/
|
参照
CalendarCountries、CalendarEventByCountry
CalendarEventById
IDによってイベントの説明を取得します。
bool CalendarEventById(
ulong event_id,
MqlCalendarEvent& event
);
|
パラメータ
event_id
[in] イベントID
event
[out] イベントの説明を受け取るためのMqlCalendarEvent型の変数
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 5402 – ERR_CALENDAR_NO_DATA(無効な国)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— ドイツの国コード(ISO 3166-1 Alpha-2)
string germany_code=“DE”;
//— ドイツのイベントを取得する
MqlCalendarEvent events[];
int events_count=CalendarEventByCountry(germany_code,events);
//— ドイツのイベントを操作ログに表示する
if(events_count>0)
{
PrintFormat(“Germany events: %d”,events_count);
ArrayPrint(events);
}
else
{
PrintFormat(“Failed to receive events for the country code %s, error %d”,
germany_code,GetLastError());
//— スクリプトが完了した
return;
}
//— events[]配列の最後のイベントの説明を取得する
MqlCalendarEvent event;
ulong event_id=events[events_count-1].id;
if(CalendarEventById(event_id,event))
{
MqlCalendarCountry country;
CalendarCountryById(event.country_id,country);
PrintFormat(“Event description with event_id=%d received”,event_id);
PrintFormat(“Country: %s (country code = %d)”,country.name,event.country_id);
PrintFormat(“Event name: %s”,event.name);
PrintFormat(“Event code: %s”,event.event_code);
PrintFormat(“Event importance: %s”,EnumToString((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance));
PrintFormat(“Event type: %s”,EnumToString((ENUM_CALENDAR_EVENT_TYPE)event.type));
PrintFormat(“Event sector: %s”,EnumToString((ENUM_CALENDAR_EVENT_SECTOR)event.sector));
PrintFormat(“Event frequency: %s”,EnumToString((ENUM_CALENDAR_EVENT_FREQUENCY)event.frequency));
PrintFormat(“Event release mode: %s”,EnumToString((ENUM_CALENDAR_EVENT_TIMEMODE)event.time_mode));
PrintFormat(“Event measurement unit: %s”,EnumToString((ENUM_CALENDAR_EVENT_UNIT)event.unit));
PrintFormat(“Number of decimal places: %d”,event.digits);
PrintFormat(“Event multiplier: %s”,EnumToString((ENUM_CALENDAR_EVENT_MULTIPLIER)event.multiplier));
PrintFormat(“Source URL: %s”,event.source_url);
}
else
PrintFormat(“Failed to get event description for event_d=%s, error %d”,
event_id,GetLastError());
}
/*
結果:
Germany events: 50
[id] [type] [sector] [frequency] [time_mode] [country_id] [unit] [importance] [multiplier] [digits] [source_url] [event_code] [name] [reserved]
[ 0] 276010001 1 6 2 0 276 1 1 0 1 “https://www.destatis.de/EN/Homepage.html” “exports-mm” “Exports m/m” 0
[ 1] 276010002 1 6 2 0 276 1 1 0 1 “https://www.destatis.de/EN/Homepage.html” “imports-mm” “Imports m/m” 0
[ 2] 276010003 1 4 2 0 276 1 1 0 1 “https://www.destatis.de/EN/Homepage.html” “import-price-index-mm” “Import Price Index m/m” 0
[ 3] 276010004 1 4 2 0 276 1 1 0 1 “https://www.destatis.de/EN/Homepage.html” “import-price-index-yy” “Import Price Index y/y” 0
….
[47] 276500001 1 8 2 0 276 0 2 0 1 “https://www.markiteconomics.com” “markit-manufacturing-pmi” “Markit Manufacturing PMI” 0
[48] 276500002 1 8 2 0 276 0 2 0 1 “https://www.markiteconomics.com” “markit-services-pmi” “Markit Services PMI” 0
[49] 276500003 1 8 2 0 276 0 2 0 1 “https://www.markiteconomics.com” “markit-composite-pmi” “Markit Composite PMI” 0
Event description with event_id=276500003 received
Country: Germany (country code = 276)
Event name: Markit Composite PMI
Event code: markit-composite-pmi
Event importance: CALENDAR_IMPORTANCE_MODERATE
Event type: CALENDAR_TYPE_INDICATOR
Event sector: CALENDAR_SECTOR_BUSINESS
Event frequency: CALENDAR_FREQUENCY_MONTH
Event release mode: CALENDAR_TIMEMODE_DATETIME
Event measurement unit: CALENDAR_UNIT_NONE
Number of decimal places: 1
Value multiplier: CALENDAR_MULTIPLIER_NONE
Source URL: https://www.markiteconomics.com
*/
|
参照
CalendarEventByCountry、CalendarEventByCurrency、 CalendarValueById
CalendarValueById
IDによってイベントの値を取得します。
bool CalendarValueById(
ulong value_id,
MqlCalendarValue& value
);
|
パラメータ
value_id
[in] イベント値ID
value
[out] イベントの説明を受け取るためのMqlCalendarValue型の変数
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 5402 – ERR_CALENDAR_NO_DATA(無効な国)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— 日本の国コード(ISO 3166-1 Alpha-2)
string japan_code=“JP”;
//— イベントを取得する期間の境界を設定する
datetime date_from=D’01.01.2018′; // 2018のすべてのイベントを取得する
datetime date_to=0; // 0はすべての既知イベント(今後起こるものを含む)
//— 日本のイベント値の配列を取得する
MqlCalendarValue values[];
int values_count=CalendarValueHistory(values,date_from,date_to,japan_code);
//— 検知されたイベント値とともに移動する
if(values_count>0)
{
PrintFormat(“Number of values for Japan events: %d”,values_count);
//— すべての「空の」値を削除する(actual_value==-9223372036854775808)
for(int i=values_count-1;i>=0;i–)
{
if(values[i].actual_value==-9223372036854775808)
ArrayRemove(values,i,1);
}
PrintFormat(“Number of values after deleting empty ones: %d”,ArraySize(values));
}
else
{
PrintFormat(“Failed to receive events for the country code %s, error %d”,
japan_code,GetLastError());
//— スクリプトが完了した
return;
}
//— values[]配列に10以上の値を残さない
if(ArraySize(values)>10)
{
PrintFormat(“Reduce the list of values to 10 and display them”);
ArrayRemove(values,0,ArraySize(values)-10);
}
ArrayPrint(values);
//— 既知のvalue_idに基づいてイベント値の説明を取得する方法を表示する
for(int i=0;i<ArraySize(values);i++)
{
MqlCalendarValue value;
CalendarValueById(values[i].id,value);
PrintFormat(“%d: value_id=%d value=%d impact=%s”,
i,values[i].id,value.actual_value,EnumToString(ENUM_CALENDAR_EVENT_IMPACT(value.impact_type)));
}
//—
}
/*
結果:
Number of values for Japan events: 1734
Number of values after deleting empty ones: 1017
Reduce the list of values to 10 and display them
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 56500 392030004 2019.03.28 23:30:00 2019.03.01 00:00:00 0 900000 600000 -9223372036854775808 500000 1 0
[1] 56501 392030005 2019.03.28 23:30:00 2019.03.01 00:00:00 0 700000 700000 -9223372036854775808 700000 0 0
[2] 56502 392030006 2019.03.28 23:30:00 2019.03.01 00:00:00 0 1100000 1100000 -9223372036854775808 900000 1 0
[3] 56544 392030007 2019.03.28 23:30:00 2019.02.01 00:00:00 0 2300000 2500000 -9223372036854775808 2200000 2 0
[4] 56556 392050002 2019.03.28 23:30:00 2019.02.01 00:00:00 0 1630000 1630000 1610000 1620000 1 0
[5] 55887 392020003 2019.03.28 23:50:00 2019.02.01 00:00:00 0 400000 600000 -9223372036854775808 1300000 2 0
[6] 55888 392020004 2019.03.28 23:50:00 2019.02.01 00:00:00 0 -1800000 -3300000 -9223372036854775808 -2000000 1 0
[7] 55889 392020002 2019.03.28 23:50:00 2019.02.01 00:00:00 0 200000 -2300000 -1800000 300000 2 0
[8] 55948 392020006 2019.03.28 23:50:00 2019.02.01 00:00:00 1 1400000 -3400000 -9223372036854775808 -300000 1 0
[9] 55949 392020007 2019.03.28 23:50:00 2019.02.01 00:00:00 1 -1000000 300000 -9223372036854775808 -100000 2 0
Display brief data on event values based on value_id
0: value_id=56500 value=900000 impact=CALENDAR_IMPACT_POSITIVE
1: value_id=56501 value=700000 impact=CALENDAR_IMPACT_NA
2: value_id=56502 value=1100000 impact=CALENDAR_IMPACT_POSITIVE
3: value_id=56544 value=2300000 impact=CALENDAR_IMPACT_NEGATIVE
4: value_id=56556 value=1630000 impact=CALENDAR_IMPACT_POSITIVE
5: value_id=55887 value=400000 impact=CALENDAR_IMPACT_NEGATIVE
6: value_id=55888 value=-1800000 impact=CALENDAR_IMPACT_POSITIVE
7: value_id=55889 value=200000 impact=CALENDAR_IMPACT_NEGATIVE
8: value_id=55948 value=1400000 impact=CALENDAR_IMPACT_POSITIVE
9: value_id=55949 value=-1000000 impact=CALENDAR_IMPACT_NEGATIVE
*/
|
参照
CalendarValueHistoryByEvent、CalendarValueHistory、 CalendarValueLastByEvent、CalendarValueLast
CalendarCountries
カレンダーで利用可能な国名の配列を取得します。
int CalendarCountries(
MqlCalendarCountry& countries[]
);
|
パラメータ
countries[]
[out] カレンダーの国の説明を受け取るためのMqlCalendarCountry型の配列
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての国の説明を受け取るには不十分で、配列に収まるものだけが受信された)
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— 経済指標カレンダーから国のリストを取得する
MqlCalendarCountry countries[];
int count=CalendarCountries(countries);
//— 操作ログに配列を表示する
if(count>0)
ArrayPrint(countries);
else
PrintFormat(“CalendarCountries() returned 0!Error %d”,GetLastError());
/*
結果:
[id] [name] [code] [currency] [currency_symbol] [url_name] [reserved]
[ 0] 0 “Worldwide” “WW” “ALL” “” “worldwide” 0
[ 1] 999 “European Union” “EU” “EUR” “€” “european-union” 0
[ 2] 840 “United States” “US” “USD” “$” “united-states” 0
[ 3] 124 “Canada” “CA” “CAD” “$” “canada” 0
[ 4] 36 “Australia” “AU” “AUD” “$” “australia” 0
[ 5] 554 “New Zealand” “NZ” “NZD” “$” “new-zealand” 0
[ 6] 392 “Japan” “JP” “JPY” “Ґ” “japan” 0
[ 7] 156 “China” “CN” “CNY” “Ґ” “china” 0
[ 8] 826 “United Kingdom” “GB” “GBP” “Ј” “united-kingdom” 0
[ 9] 756 “Switzerland” “CH” “CHF” “₣” “switzerland” 0
[10] 276 “Germany” “DE” “EUR” “€” “germany” 0
[11] 250 “France” “FR” “EUR” “€” “france” 0
[12] 380 “Italy” “IT” “EUR” “€” “italy” 0
[13] 724 “Spain” “ES” “EUR” “€” “spain” 0
[14] 76 “Brazil” “BR” “BRL” “R$” “brazil” 0
[15] 410 “South Korea” “KR” “KRW” “₩” “south-korea” 0
*/
}
|
参照
CalendarEventByCountry、CalendarCountryById
CalendarEventByCountry
指定された国コードでカレンダーで利用可能なすべてのイベントの説明の配列を取得します。
int CalendarEventByCountry(
string country_code,
MqlCalendarEvent& events[]
);
|
パラメータ
country_code
[in] 国コード名(ISO 3166-1 alpha-2)
events[]
[out] 指定された国の説明を受け取るためのMqlCalendarEvent型配列
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- ArrayResize()操作の実行エラー
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— EUの国コード(ISO 3166-1 Alpha-2)
string EU_code=“EU”;
//— EUイベントを取得する
MqlCalendarEvent events[];
int events_count=CalendarEventByCountry(EU_code,events);
//— EUイベントを操作ログに表示する
if(events_count>0)
{
PrintFormat(“EU events: %d”,events_count);
ArrayPrint(events);
}
//—
}
/*
結果:
EU events: 56
[id] [type] [country_id] [unit] [importance] [multiplier] [digits] [event_code]
[ 0] 999010001 0 999 0 2 0 0 “ECB Non-monetary Policy Meeting”
[ 1] 999010002 0 999 0 2 0 0 “ECB Monetary Policy Meeting Account
[ 2] 999010003 0 999 0 3 0 0 “ECB Monetary Policy Press Conferenc
[ 3] 999010004 0 999 0 3 0 0 “ECB President Draghi Speech”
[ 4] 999010005 0 999 0 2 0 0 “ECB Vice President Constancio Speec
[ 5] 999010006 1 999 1 3 0 2 “ECB Deposit Facility Rate Decision”
[ 6] 999010007 1 999 1 3 0 2 “ECB Interest Rate Decision”
[ 7] 999010008 0 999 0 2 0 0 “ECB Economic Bulletin”
[ 8] 999010009 1 999 2 2 3 3 “ECB Targeted LTRO”
[ 9] 999010010 0 999 0 2 0 0 “ECB Executive Board Member Praet Sp
[10] 999010011 0 999 0 2 0 0 “ECB Executive Board Member Mersch S
…
*/
|
参照
CalendarCountries、CalendarCountryById
CalendarEventByCurrency
指定された通貨でカレンダーで利用可能なすべてのイベントの説明の配列を取得します。
int CalendarEventByCurrency(
const string currency,
MqlCalendarEvent& events[]
);
|
パラメータ
currency
[in] 国の通貨のコード名
events[]
[out] 指定された通貨の説明を受け取るためのMqlCalendarEvent型配列
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- ArrayResize()操作の実行エラー
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— 経済指標カレンダーを受け取るための配列を宣言する
MqlCalendarEvent events[];
//— EU通貨イベントを取得する
int count = CalendarEventByCurrency(“EUR”,events);
Print(“count = “, count);
//— この例では10イベントで足りる
if(count>10)
ArrayResize(events,10);
//— 操作ログにイベントを表示する
ArrayPrint(events);
}
/*
結果:
[id] [type] [country_id] [unit] [importance] [source_url] [event_code] [name]
[0] 999010001 0 999 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-non-monetary-policy-meeting” “ECB Non-monetary Policy Meeting”
[1] 999010002 0 999 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-monetary-policy-meeting-accounts” “ECB Monetary Policy Meeting Accounts”
[2] 999010003 0 999 0 3 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-monetary-policy-press-conference” “ECB Monetary Policy Press Conference”
[3] 999010004 0 999 0 3 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-president-draghi-speech” “ECB President Draghi Speech”
[4] 999010005 0 999 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-vice-president-vitor-constancio-speech” “ECB Vice President Constancio Speech”
[5] 999010006 1 999 1 3 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-deposit-rate-decision” “ECB Deposit Facility Rate Decision”
[6] 999010007 1 999 1 3 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-interest-rate-decision” “ECB Interest Rate Decision”
[7] 999010008 0 999 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-economic-bulletin” “ECB Economic Bulletin”
[8] 999010009 1 999 2 2 “https://www.ecb.europa.eu/home/html/index.en.html” “targeted-ltro” “ECB Targeted LTRO”
[9] 999010010 0 999 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-executive-board-member-praet-speech” “ECB Executive Board Member Praet Speech”
*/
|
参照
CalendarEventById、CalendarEventByCountry
CalendarValueHistoryByEvent
イベントIDによって、指定された期間のすべてのイベントの値の配列を取得します。
bool CalendarValueHistoryByEvent(
ulong event_id,
MqlCalendarValue& values[],
datetime datetime_from,
datetime datetime_to=0
);
|
パラメータ
event_id
[in] イベントID
values[]
[out] イベント値を受け取るためのMqlCalendarValue型の配列
datetime_from
[in] 指定されたIDによって選択された、期間内のイベントの開始日(datetime_from < datetime_to)
datetime_to=0
[in] 指定されたIDによって選択された期間内のイベントの終了日。datetime_to が設定されていない場合(または0の場合)、指定されたdatetime_from以降のカレンダーデータベースのすべてのイベント値が返されます(将来のイベントを含む)。
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての値の説明を受け取るには不十分で、配列に収まるものだけが受信された)
struct MqlCalendarValue
{
…
long actual_value; // イベントの実際の値
long prev_value; // イベントの以前の値
long revised_prev_value; // イベントの改正された以前の値
long forecast_value; // イベントの予測値
…
};
|
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— EUの国コード(ISO 3166-1 Alpha-2)
string EU_code=“EU”;
//— EUイベントを取得する
MqlCalendarEvent events[];
int events_count=CalendarEventByCountry(EU_code,events);
//— EUイベントを操作ログに表示する
if(events_count>0)
{
PrintFormat(“EU events: %d”,events_count);
//— 分析には10イベントで十分であるため、イベントリストを減らす
ArrayResize(events,10);
ArrayPrint(events);
}
//— “ECB Interest Rate Decision”イベントがevent_id=999010007であることを確認する
ulong event_id=events[6].id; // イベントのIDはカレンダーで変わる可能性があるので、必ず確認する
string event_name=events[6].name; // カレンダーイベントの名前
PrintFormat(“Get values for event_name=%s event_id=%d”,event_name,event_id);
//— “ECB Interest Rate Decision”イベントのすべての値を取得する
MqlCalendarValue values[];
//— イベントを取得する期間の境界を設定する
datetime date_from=0; // 利用可能な履歴の初めからのすべてのイベントをとる
datetime date_to=D’01.01.2016′; // 2016以降のイベントをとる
if(CalendarValueHistoryByEvent(event_id,values,date_from,date_to))
{
PrintFormat(“Received values for %s: %d”,
event_name,ArraySize(values));
//— 分析には10イベントで十分であるため、値リストを減らす
ArrayResize(values,10);
ArrayPrint(values);
}
else
{
PrintFormat(“Error!Failed to get values for event_id=%d”,event_id);
PrintFormat(“Error code: %d”,GetLastError());
}
}
//—
/*
結果:
EU events: 56
[id] [type] [sector] [frequency] [time_mode] [country_id] [unit] [importance] [multiplier] [digits] [source_url] [event_code] [name] [reserv
[0] 999010001 0 5 0 0 999 0 2 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-non-monetary-policy-meeting” “ECB Non-monetary Policy Meeting”
[1] 999010002 0 5 0 0 999 0 2 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-monetary-policy-meeting-accounts” “ECB Monetary Policy Meeting Accounts”
[2] 999010003 0 5 0 0 999 0 3 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-monetary-policy-press-conference” “ECB Monetary Policy Press Conference”
[3] 999010004 0 5 0 0 999 0 3 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-president-draghi-speech” “ECB President Draghi Speech”
[4] 999010005 0 5 0 0 999 0 2 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-vice-president-vitor-constancio-speech” “ECB Vice President Constancio Speech”
[5] 999010006 1 5 0 0 999 1 3 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-deposit-rate-decision” “ECB Deposit Facility Rate Decision”
[6] 999010007 1 5 0 0 999 1 3 0 2 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-interest-rate-decision” “ECB Interest Rate Decision”
[7] 999010008 0 5 0 0 999 0 2 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-economic-bulletin” “ECB Economic Bulletin”
[8] 999010009 1 5 0 0 999 2 2 3 3 “https://www.ecb.europa.eu/home/html/index.en.html” “targeted-ltro” “ECB Targeted LTRO”
[9] 999010010 0 5 0 0 999 0 2 0 0 “https://www.ecb.europa.eu/home/html/index.en.html” “ecb-executive-board-member-praet-speech” “ECB Executive Board Member Praet Speech”
Get values for event_name=ECB Interest Rate Decision event_id=999010007
Received ECB Interest Rate Decision event values: 102
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 2776 999010007 2007.03.08 11:45:00 1970.01.01 00:00:00 0 3750000 4250000 -9223372036854775808 -9223372036854775808 0 0
[1] 2777 999010007 2007.05.10 11:45:00 1970.01.01 00:00:00 0 3750000 3750000 -9223372036854775808 -9223372036854775808 0 0
[2] 2778 999010007 2007.06.06 11:45:00 1970.01.01 00:00:00 0 4000000 3750000 -9223372036854775808 -9223372036854775808 0 0
[3] 2779 999010007 2007.07.05 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[4] 2780 999010007 2007.08.02 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[5] 2781 999010007 2007.09.06 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[6] 2782 999010007 2007.10.04 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[7] 2783 999010007 2007.11.08 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[8] 2784 999010007 2007.12.06 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[9] 2785 999010007 2008.01.10 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
*/
|
参照
CalendarCountries、CalendarEventByCountry、 CalendarValueHistory、CalendarEventById、CalendarValueById
CalendarValueHistory
指定された期間のすべてのイベントの値の配列を取得します(国や通貨で並び替え可能)。
bool CalendarValueHistory(
MqlCalendarValue& values[],
datetime datetime_from,
datetime datetime_to=0
const string country_code=NULL,
const string currency=NULL
);
|
パラメータ
values[]
[out] イベント値を受け取るためのMqlCalendarValue型の配列
datetime_from
[in] 指定されたIDによって選択された、期間内のイベントの開始日(datetime_from < datetime_to)
datetime_to=0
[in] 指定されたIDによって選択された期間内のイベントの終了日。datetime_to が設定されていない場合(または0の場合)、指定されたdatetime_from以降のカレンダーデータベースのすべてのイベント値が返されます(将来のイベントを含む)。
country_code=NULL
[in] 国コード名(ISO 3166-1 alpha-2)
currency=NULL
[in] 国の通貨のコード名
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての値の説明を受け取るには不十分で、配列に収まるものだけが受信された)
注意事項
struct MqlCalendarValue
{
…
long actual_value; // イベントの実際の値
long prev_value; // イベントの以前の値
long revised_prev_value; // イベントの改正された以前の値
long forecast_value; // イベントの予測値
…
};
|
例:
//+——————————————————————+
//| スクリプトプログラム開始関数 |
//+——————————————————————+
void OnStart()
{
//— EUの国コード(ISO 3166-1 Alpha-2)
string EU_code=“EU”;
//— EUイベント値を取得する
MqlCalendarValue values[];
//— イベントを取得する期間の境界を設定する
datetime date_from=D’01.01.2018′; // 2018のすべてのイベントを取得する
datetime date_to=0; // 0はすべての既知イベント(今後起こるものを含む)
//— 2018年以来のEUイベント履歴をリクエストする
if(CalendarValueHistory(values,date_from,date_to,EU_code))
{
PrintFormat(“Received event values for country_code=%s: %d”,
EU_code,ArraySize(values));
//— 操作ログに出力する配列サイズを減らす
ArrayResize(values,10);
//— 操作ログにイベント値を表示する
ArrayPrint(values);
}
else
{
PrintFormat(“Error!Failed to receive events for country_code=%s”,EU_code);
PrintFormat(“Error code: %d”,GetLastError());
}
//—
}
/*
結果:
Received event values for country_code=EU: 1384
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 54215 999500001 2018.01.02 09:00:00 2017.12.01 00:00:00 3 60600000 60600000 -9223372036854775808 60500000 1 0
[1] 54221 999500002 2018.01.04 09:00:00 2017.12.01 00:00:00 3 56600000 56500000 -9223372036854775808 56000000 1 0
[2] 54222 999500003 2018.01.04 09:00:00 2017.12.01 00:00:00 3 58100000 58000000 -9223372036854775808 58400000 2 0
[3] 45123 999030005 2018.01.05 10:00:00 2017.11.01 00:00:00 0 600000 400000 -9223372036854775808 100000 1 0
[4] 45124 999030006 2018.01.05 10:00:00 2017.11.01 00:00:00 0 2800000 2500000 -9223372036854775808 1500000 1 0
[5] 45125 999030012 2018.01.05 10:00:00 2017.12.01 00:00:00 1 900000 900000 -9223372036854775808 1000000 2 0
[6] 45126 999030013 2018.01.05 10:00:00 2017.12.01 00:00:00 1 1400000 1500000 -9223372036854775808 1500000 2 0
[7] 54953 999520001 2018.01.05 20:30:00 2018.01.02 00:00:00 0 127900000 92100000 -9223372036854775808 76400000 0 0
[8] 22230 999040003 2018.01.08 10:00:00 2017.12.01 00:00:00 0 9100000 8200000 8100000 7600000 1 0
[9] 22231 999040004 2018.01.08 10:00:00 2017.12.01 00:00:00 0 18400000 16300000 16400000 16800000 1 0
*/
|
参照
CalendarCountries、CalendarEventByCountry、 CalendarValueHistoryByEvent、CalendarEventById、 CalendarValueById
CalendarValueLastByEvent
指定されたchange_idで、カレンダーデータベースのステータスからイベントIDの配列をIDで取得します。
int CalendarValueLastByEvent(
ulong event_id,
ulong& change_id,
MqlCalendarValue& values[]
);
|
パラメータ
event_id
[in] イベントID
change_id
[in][out] 変化ID
values[]
[out] イベント値を受け取るためのMqlCalendarValue型の配列
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての値の説明を受け取るには不十分で、配列に収まるものだけが受信された)
注意事項
struct MqlCalendarValue
{
…
long actual_value; // イベントの実際の値
long prev_value; // イベントの以前の値
long revised_prev_value; // イベントの改正された以前の値
long forecast_value; // イベントの予測値
…
};
|
非農業部門就業者数の公開リスナーであるサンプルEA:
#property description “Example of using the CalendarValueLastByEvent function”
#property description ” for tracking the release of the Nonfarm Payrolls report.”
#property description “To achieve this, get the current change ID”
#property description ” of the Calendar database. Then, use this ID to receive”
#property description ” only new events via the timer survey”
//+——————————————————————+
//| エキスパート初期化関数 |
//+——————————————————————+
int OnInit()
{
//— タイマーを作成する
EventSetTimer(60);
//—
return(INIT_SUCCEEDED);
}
//+——————————————————————+
//| エキスパート初期化解除関数 |
//+——————————————————————+
void OnDeinit(const int reason)
{
//— タイマーを破壊する
EventKillTimer();
}
//+——————————————————————+
//| エキスパートティック関数 |
//+——————————————————————+
void OnTick()
{
//—
}
//+——————————————————————+
//| Timer関数 |
//+——————————————————————+
void OnTimer()
{
//— カレンダーデータベース変更ID
static ulong calendar_change_id=0;
//— 1番目の実行属性
static bool first=true;
//— イベントID
static ulong event_id=0;
//— イベント名
static string event_name=NULL;
//— イベント値の配列
MqlCalendarValue values[];
//— 初期化を行う – 現在のcalendar_change_idを取得する
if(first)
{
MqlCalendarEvent events[];
//— 米国の国コード(ISO 3166-1 Alpha-2)
string USA_code=“US”;
//— 米国のイベントを取得する
int events_count=CalendarEventByCountry(USA_code,events);
//— 必要なイベントの’events’配列内の位置
int event_pos=-1;
//— 米国のイベントを操作ログに表示する
if(events_count>0)
{
PrintFormat(“%s: USA events: %d”,__FUNCTION__,events_count);
for(int i=0;i<events_count;i++)
{
string event_name_low=events[i].name;
//— イベント名を小文字に変換する
if(!StringToLower(event_name_low))
{
PrintFormat(“StringToLower() returned %d error”,GetLastError());
//— 前もって関数を終了する
return;
}
//— 「非農業部門就業者数」イベントを探す
if(StringFind(event_name_low,“nonfarm payrolls”)!=-1)
{
//— イベントが見つかったのでIDを記憶する
event_id=events[i].id;
//— 「非農業部門就業者数」イベント名を書く
event_name=events[i].name;
//— イベントの’events[]’ 配列内の位置を記憶する
event_pos=i;
//— カレンダーには名前に「非農業部門就業者数」を含むイベントが複数ある
PrintFormat(“Event \”Nonfarm Payrolls\” found: event_id=%d event_name=%s”,event_id,event_name);
//— この例をよく理解するためには、’break’演算子をコメントアウトしてすべてのイベントを表示できる
break;
}
}
//— 「非農業部門就業者数」以降のイベントを削除してリストを減らす
ArrayRemove(events,event_pos+1);
//— より便利な分析のために「非農業部門就業者数」以前の9つのイベントをそのままにする
ArrayRemove(events,0,event_pos-9);
ArrayPrint(events);
}
else
{
PrintFormat(“%s: CalendarEventByCountry(%s) returned 0 events, error code=%d”,
USA_code,__FUNCTION__,GetLastError());
//— 操作は失敗して終了したため、タイマーの次の呼び出し中に再試行する
return;
}
//— 指定されたイベントのカレンダーデータベース変更IDを取得する
if(CalendarValueLastByEvent(event_id,calendar_change_id,values)>0)
{
//— このコードブロックは最初の起動時には実行できないがとにかく追加する
PrintFormat(“%s: Received the Calendar database current ID: change_id=%d”,
__FUNCTION__,calendar_change_id);
//— フラグを設定してタイマーの次のイベントの前に終了する
first=false;
return;
}
else
{
//— データが受信されない)これは最初の起動では正常である)、エラーがないか確認する
int error_code=GetLastError();
if(error_code==0)
{
PrintFormat(“%s: Received the Calendar database current ID: change_id=%d”,
__FUNCTION__,calendar_change_id);
//— フラグを設定してタイマーの次のイベントの前に終了する
first=false;
//— calendar_change_idを取得した
return;
}
else
{
//— 本当のエラー
PrintFormat(“%s: Failed to get values for event_id=%d”,__FUNCTION__,event_id);
PrintFormat(“Error code: %d”,error_code);
//— 操作は失敗して終了したため、タイマーの次の呼び出し中に再試行する
return;
}
}
}
//— カレンダーの変更IDの最後の既知の値(change_id)がある
ulong old_change_id=calendar_change_id;
//— 「非農業部門就業者数」イベント値を確認する
if(CalendarValueLastByEvent(event_id,calendar_change_id,values)>0)
{
PrintFormat(“%s: Received new events for \”%s\“: %d”,
__FUNCTION__,event_name,ArraySize(values));
//— ‘values’配列のデータを操作ログで表示する
ArrayPrint(values);
//— 前のカレンダーIDと新しいカレンダーIDの値を操作ログで表示する
PrintFormat(“%s: Previous change_id=%d, new change_id=%d”,
__FUNCTION__,old_change_id,calendar_change_id);
/*
非農業部門就業者数データの発表を処理するコードをここで書く
*/
}
//—
}
/*
結果:
OnTimer: USA events: 202
Event “Nonfarm Payrolls” found: event_id=840030016 event_name=Nonfarm Payrolls
[id] [type] [sector] [frequency] [time_mode] [country_id] [unit] [importance] [multiplier] [digits] [source_url] [event_code] [name] [reserved]
[0] 840030007 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “consumer-price-index-yy” “CPI y/y” 0
[1] 840030008 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “consumer-price-index-ex-food-energy-yy” “Core CPI y/y” 0
[2] 840030009 1 4 2 0 840 0 1 0 3 “https://www.bls.gov” “consumer-price-index-nsa” “CPI n.s.a.” 0
[3] 840030010 1 4 2 0 840 0 1 0 3 “https://www.bls.gov” “consumer-price-index-ex-food-energy” “Core CPI” 0
[4] 840030011 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “import-price-index-mm” “Import Price Index m/m” 0
[5] 840030012 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “import-price-index-yy” “Import Price Index y/y” 0
[6] 840030013 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “export-price-index-mm” “Export Price Index m/m” 0
[7] 840030014 1 4 2 0 840 1 1 0 1 “https://www.bls.gov” “export-price-index-yy” “Export Price Index y/y” 0
[8] 840030015 1 3 2 0 840 1 2 0 1 “https://www.bls.gov” “unemployment-rate” “Unemployment Rate” 0
[9] 840030016 1 3 2 0 840 4 3 1 0 “https://www.bls.gov” “nonfarm-payrolls” “Nonfarm Payrolls” 0
OnTimer: Received the Calendar database current ID: change_id=33986560
*/
|
参照
CalendarValueLast、CalendarValueHistory、 CalendarValueHistoryByEvent、CalendarValueById
CalendarValueLast
指定されたchange_idで、カレンダデータベースのステータスからすべてのイベントの値の配列を取得します(国や通貨で並び替え可能)。
int CalendarValueLast(
ulong& change_id,
MqlCalendarValue& values[],
const string country_code=NULL,
const string currency=NULL
);
|
パラメータ
change_id
[in][out] 変化ID
values[]
[out] イベント値を受け取るためのMqlCalendarValue型の配列
country_code=NULL
[in] 国コード名(ISO 3166-1 alpha-2)
currency=NULL
[in] 国の通貨のコード名
戻り値
- 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
- 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
- 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
- 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての値の説明を受け取るには不十分で、配列に収まるものだけが受信された)
注意事項
struct MqlCalendarValue
{
…
long actual_value; // イベントの実際の値
long prev_value; // イベントの以前の値
long revised_prev_value; // イベントの改正された以前の値
long forecast_value; // イベントの予測値
…
};
|
経済指標カレンダーイベントを聴取するサンプルEA:
#property description “Example of using the CalendarValueLast function”
#property description ” to develop the economic calendar events listener.”
#property description “To achieve this, get the current change ID”
#property description ” of the Calendar database. Then, use this ID to receive”
#property description ” only new events via the timer survey”
//+——————————————————————+
//| エキスパート初期化関数 |
//+——————————————————————+
int OnInit()
{
//— タイマーを作成する
EventSetTimer(60);
//—
return(INIT_SUCCEEDED);
}
//+——————————————————————+
//| エキスパート初期化解除関数 |
//+——————————————————————+
void OnDeinit(const int reason)
{
//— タイマーを破壊する
EventKillTimer();
}
//+——————————————————————+
//| エキスパートティック関数 |
//+——————————————————————+
void OnTick()
{
//—
}
//+——————————————————————+
//| Timer関数 |
//+——————————————————————+
void OnTimer()
{
//— カレンダーデータベース変更ID
static ulong calendar_change_id=0;
//— 1番目の実行属性
static bool first=true;
//— イベント値の配列
MqlCalendarValue values[];
//— 初期化を行う – 現在のcalendar_change_idを取得する
if(first)
{
//— カレンダーデータベース変更IDを取得する
if(CalendarValueLast(calendar_change_id,values)>0)
{
//— このコードブロックは最初の起動時には実行できないがとにかく追加する
PrintFormat(“%s: Received the Calendar database current ID: change_id=%d”,
__FUNCTION__,calendar_change_id);
//— フラグを設定してタイマーの次のイベントの前に終了する
first=false;
return;
}
else
{
//— データが受信されない)これは最初の起動では正常である)、エラーがないか確認する
int error_code=GetLastError();
if(error_code==0)
{
PrintFormat(“%s: Received the Calendar database current ID: change_id=%d”,
__FUNCTION__,calendar_change_id);
//— フラグを設定してタイマーの次のイベントの前に終了する
first=false;
//— calendar_change_idを取得した
return;
}
else
{
//— 本当のエラー
PrintFormat(“%s: Failed to get events in CalendarValueLast. Error code: %d”,
__FUNCTION__,error_code);
//— 操作は失敗して終了し、タイマーの次の呼び出し中に再初期化される
return;
}
}
}
//— カレンダーの変更IDの最後の既知の値(change_id)がある
ulong old_change_id=calendar_change_id;
//— 新しいカレンダーイベントがあるかどうか確認する
if(CalendarValueLast(calendar_change_id,values)>0)
{
PrintFormat(“%s: Received new Calendar events: %d”,
__FUNCTION__,ArraySize(values));
//— ‘values’配列のデータを操作ログで表示する
ArrayPrint(values);
//— 前のカレンダーIDと新しいカレンダーIDの値を操作ログで表示する
PrintFormat(“%s: Previous change_id=%d, new change_id=%d”,
__FUNCTION__,old_change_id,calendar_change_id);
//— 新しいイベントを操作ログで表示する
ArrayPrint(values);
/*
ここでイベントの発生を処理するためのコードを書く
*/
}
//—
}
/*
リスナー操作の例:
OnTimer: Received the Calendar database current ID: change_id=33281792
OnTimer: Received new events for the Calendar: 1
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 91040 76020013 2019.03.20 15:30:00 1970.01.01 00:00:00 0 -5077000 -1913000 -9223372036854775808 -4077000 2 0
OnTimer: Previous change_id=33281792, new change_id=33282048
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 91040 76020013 2019.03.20 15:30:00 1970.01.01 00:00:00 0 -5077000 -1913000 -9223372036854775808 -4077000 2 0
OnTimer: Received new events for the Calendar: 1
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 91041 76020013 2019.03.27 15:30:00 1970.01.01 00:00:00 0 -9223372036854775808 -5077000 -9223372036854775808 -7292000 0 0
OnTimer: Previous change_id=33282048, new change_id=33282560
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 91041 76020013 2019.03.27 15:30:00 1970.01.01 00:00:00 0 -9223372036854775808 -5077000 -9223372036854775808 -7292000 0 0
*/
|
参照
CalendarValueLast、CalendarValueHistory、 CalendarValueHistoryByEvent、CalendarValueById
Originally posted 2019-07-29 23:24:27.