void OnStart()
{
datetime from=0;
datetime to=TimeCurrent();
//--- 履歴全部をリクエストする
HistorySelect(from,to);
//--- 注文プロパティから値を返す変数
ulong ticket;
double open_price;
double initial_volume;
datetime time_setup;
datetime time_done;
string symbol;
string type;
long order_magic;
long positionID;
//--- 現在の未決注文数
uint total=HistoryOrdersTotal();
//--- ループで注文をみる
for(uint i=0;i<total;i++)
{
//--- リスト内の位置によって注文を返す
if((ticket=HistoryOrderGetTicket(i))>0)
{
//--- 注文プロパティを返す
open_price =HistoryOrderGetDouble(ticket,ORDER_PRICE_OPEN);
time_setup =(datetime)HistoryOrderGetInteger(ticket,ORDER_TIME_SETUP);
time_done =(datetime)HistoryOrderGetInteger(ticket,ORDER_TIME_DONE);
symbol =HistoryOrderGetString(ticket,ORDER_SYMBOL);
order_magic =HistoryOrderGetInteger(ticket,ORDER_MAGIC);
positionID =HistoryOrderGetInteger(ticket,ORDER_POSITION_ID);
initial_volume=HistoryOrderGetDouble(ticket,ORDER_VOLUME_INITIAL);
type =GetOrderType(HistoryOrderGetInteger(ticket,ORDER_TYPE));
//--- 注文についての情報を準備して表示する
printf("#ticket %d %s %G %s at %G was set up at %s => done at %s, pos ID=%d",
ticket, // 注文チケット
type, // 種類
initial_volume, // 注文のボリューム
symbol, // シンボル
open_price, // 指定された始値
TimeToString(time_setup),// 注文の出された時刻
TimeToString(time_done), // 注文実行または削除の時刻
positionID // 注文の約定が含まれたポジションの識別子
);
}
}
//---
}
//+------------------------------------------------------------------+
//| 注文の種類を文字列として返す |
//+------------------------------------------------------------------+
string GetOrderType(long type)
{
string str_type="unknown operation";
switch(type)
{
case (ORDER_TYPE_BUY): return("buy");
case (ORDER_TYPE_SELL): return("sell");
case (ORDER_TYPE_BUY_LIMIT): return("buy limit");
case (ORDER_TYPE_SELL_LIMIT): return("sell limit");
case (ORDER_TYPE_BUY_STOP): return("buy stop");
case (ORDER_TYPE_SELL_STOP): return("sell stop");
case (ORDER_TYPE_BUY_STOP_LIMIT): return("buy stop limit");
case (ORDER_TYPE_SELL_STOP_LIMIT):return("sell stop limit");
}
return(str_type);
}
|