#property copyright "@老顽童"
#property link "https://www.mql5.com"
#property version "1.1"
#property icon "//include//logo.ico"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
历史订单信息(Symbol(),0,1,0,TimeCurrent(),true,1);
}
//+------------------------------------------------------------------+
void 历史订单信息(string 币种,long magic,int 倒数第几,ulong 起始时间,ulong 截止时间,bool 是否打印,ENUM_DEAL_ENTRY 进出)
{
int 计数=0;
HistorySelect(起始时间,截止时间);
for(int i=HistoryDealsTotal()-1; i>=0; i--)
{
if(HistoryDealGetString(HistoryDealGetTicket(i),DEAL_SYMBOL)==币种&&HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_MAGIC)==magic&&HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_ENTRY)==进出)
{
string 历史持仓币种=HistoryDealGetString(HistoryDealGetTicket(i),DEAL_SYMBOL);
double 历史持仓交易量=HistoryDealGetDouble(HistoryDealGetTicket(i),DEAL_VOLUME);
double 历史持仓止损=HistoryDealGetDouble(HistoryDealGetTicket(i),DEAL_SL);
double 历史持仓止盈=HistoryDealGetDouble(HistoryDealGetTicket(i),DEAL_TP);
ENUM_DEAL_TYPE 历史持仓类型=(ENUM_DEAL_TYPE)HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_TYPE); // 持仓类型
long 历史持仓订单号=HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_TICKET);
ulong 历史持仓magic=HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_MAGIC);
string 历史持仓注释=HistoryDealGetString(HistoryDealGetTicket(i),DEAL_COMMENT);
double 历史持仓开盘价=HistoryDealGetDouble(HistoryDealGetTicket(i),DEAL_PRICE);
long 历史持仓开盘服务器时间=HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_TIME);
long 历史持仓开盘电脑时间=HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_TIME)-TimeCurrent()+TimeLocal();
ulong 历史ID=HistoryDealGetInteger(HistoryDealGetTicket(i),DEAL_POSITION_ID);
Comment(
"历史单信息更新\n"+
(string)历史持仓币种+ "\n",
(string)历史持仓交易量+ "\n",
(string)历史持仓止损+ "\n",
(string)历史持仓止盈+ "\n",
(string)历史持仓类型 + "\n",// 持仓类型
(string)历史持仓订单号+ "\n",
(string)历史持仓magic+ "\n",
(string)历史持仓注释+ "\n",
(string)历史持仓开盘价+ "\n",
(string)历史持仓开盘服务器时间+ "\n",
(string)历史持仓开盘电脑时间+ "\n",
(string)历史ID);
if(是否打印)
Print(
"历史单信息更新\n"+
(string)历史持仓币种+ "\n",
(string)历史持仓交易量+ "\n",
(string)历史持仓止损+ "\n",
(string)历史持仓止盈+ "\n",
(string)历史持仓类型 + "\n",// 持仓类型
(string)历史持仓订单号+ "\n",
(string)历史持仓magic+ "\n",
(string)历史持仓注释+ "\n",
(string)历史持仓开盘价+ "\n",
(string)历史持仓开盘服务器时间+ "\n",
(string)历史持仓开盘电脑时间+ "\n",
(string)历史ID);
计数++;
if(计数==倒数第几)
break;
}
}
} |