09月22日, 2014 1964次
//+------------------------------------------------------------------+
//| gethist.mq5 |
//| Copyright 2023, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
CheckEachOrder();
}
//+------------------------------------------------------------------+
void CheckEachOrder() {
color BuyColor =clrBlue;
color SellColor=clrRed;
//--- 请求交易历史记录
HistorySelect(0,TimeCurrent());
//--- 创建物件
// string name;
uint total ;
ulong ticket=0;
double price;
double profit;
double volume;
datetime time;
string symbol;
long type;
long entry;
//--- 所有交易
//--- 公司名称
string company=AccountInfoString(ACCOUNT_COMPANY);
//--- 客户名称
string name=AccountInfoString(ACCOUNT_NAME);
//--- 账号
long login=AccountInfoInteger(ACCOUNT_LOGIN);
//--- 服务器名称
string server=AccountInfoString(ACCOUNT_SERVER);
//--- 账户货币
string currency=AccountInfoString(ACCOUNT_CURRENCY);
// string accontinfo=AccountInfoString(ACCOUNT_COMPANY)+"~"+AccountInfoString(ACCOUNT_CURRENCY)+"~"+AccountInfoString(ACCOUNT_NAME)+"~"+AccountInfoString(ACCOUNT_SERVER);
string accontinfo=login+" "+AccountInfoString(ACCOUNT_COMPANY)+" "+AccountInfoString(ACCOUNT_CURRENCY)+" "+AccountInfoString(ACCOUNT_NAME)+" "+AccountInfoString(ACCOUNT_SERVER);
datetime from_date=0;//D'2023.03.12'; // 从最开始
datetime to_date=TimeCurrent();// 到当前时间
//--- 特定周期中请求交易历史记录
HistorySelect(from_date,to_date);
total=HistoryDealsTotal();
for(uint i=0;i<total;i++)
{
//--- 尽力获得交易报价
if((ticket=HistoryDealGetTicket(i))>0)
{
//--- 获得交易属性
price =HistoryDealGetDouble(ticket,DEAL_PRICE);
volume =HistoryDealGetDouble(ticket,DEAL_VOLUME);
time =HistoryDealGetInteger(ticket,DEAL_TIME);
symbol=HistoryDealGetString(ticket,DEAL_SYMBOL);
type =HistoryDealGetInteger(ticket,DEAL_TYPE);
entry =HistoryDealGetInteger(ticket,DEAL_ENTRY);
profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
//--- 只对当前交易品种
if(price && time && 1) //symbol==Symbol()
{
//--- 创建价格物件
name="TradeHistory_Deal_"+string(ticket);
Print(name);
string cookie=NULL,headers;
char post[],result[];
string url="http://192.168.1.22/ea.php";
//url=url+"?op="+name+"|"+total+"|" +symbol+"|"+price+"|"+volume+"|" +time+"|"+type+"|"+entry+"|"+profit+"|"+accontinfo;
url=url+"?op="+name+"|"+total+"|" +symbol+"|"+price+"|"+volume+"|" +time+"|"+type+"|"+entry+"|"+profit+"|"+accontinfo;
ResetLastError();
int res=WebRequest("GET",url,cookie,NULL,500,post,0,result,headers);
/*
string subfolder="Research";
int filehandle=FileOpen(subfolder+"\\fractals.txt",FILE_WRITE|FILE_CSV);
if(filehandle!=INVALID_HANDLE)
{
FileWrite(filehandle, name);
FileClose(filehandle);
}
if(entry) ObjectCreate(0,name,OBJ_ARROW_RIGHT_PRICE,0,time,price,0,0);
else ObjectCreate(0,name,OBJ_ARROW_LEFT_PRICE,0,time,price,0,0);
//--- 设置物件属性
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);
ObjectSetInteger(0,name,OBJPROP_BACK,0);
ObjectSetInteger(0,name,OBJPROP_COLOR,type?BuyColor:SellColor);
if(profit!=0) ObjectSetString(0,name,OBJPROP_TEXT,"Profit: "+string(profit));
*/
}
}
}
//--- 应用于图表
// ChartRedraw();
}
暂无留言,赶快评论吧