CalendarValueHistoryByEvent

イベントIDによって、指定された期間のすべてのイベントの値の配列を取得します。

bool  CalendarValueHistoryByEvent(
  ulong              event_id,          // イベント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以降のカレンダーデータベースのすべてのイベント値が返されます(将来のイベントを含む)。

戻り値

成功の場合は true、それ以外の場合は false。エラー情報を取得するためにはGetLastError()関数を呼び出します。可能なエラー:

  • 4001 – ERR_INTERNAL_ERROR(一般的なランタイムエラー)
  • 4004 – ERR_NOT_ENOUGH_MEMORY(メモリが操作完了に不充分)
  • 5401 – ERR_CALENDAR_TIMEOUT(リクエスト制限時間の超過)
  • 5400 – ERR_CALENDAR_MORE_DATA(配列サイズはすべての値の説明を受け取るには不十分で、配列に収まるものだけが受信された)

注意事項

経済指標カレンダーを使用するためのすべての関数は、取引サーバ時間(TimeTradeServer)を使用します。つまり、MqlCalendarValue構造体の時刻と、CalendarValueHistoryByEvent/CalendarValueHistory関数は、ユーザの現地時間ではなく、取引サーバの時間帯で設定されます。

MqlCalendarValue構造体はactual_value、forecast_value、prev_value、revised_prev_valueフィールドの値を確認/設定するメソッドを備えています。値が指定されていない場合、フィールドにはLONG_MIN (-9223372036854775808)が格納されます。

これらのフィールドに格納されている値は100万倍されることに注意してください。CalendarValueByIdCalendarValueHistoryByEventCalendarValueHistoryCalendarValueLastByEventCalendarValueLastのいずれかの関数を使用してMqlCalendarValueで値を受け取る場合、フィールド値がLONG_MINに等しいかどうかを確認する必要があります。フィールドに値が指定されている場合、値を取得するには、値を100万で除算する必要があります。値を取得するもう1つの方法は、MqlCalendarValue構造体の関数を使用して値を確認および取得することです。

例:

//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数                                              |
//+------------------------------------------------------------------+
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
*/

 

参照

CalendarCountriesCalendarEventByCountryCalendarValueHistoryCalendarEventByIdCalendarValueById