下载MetaTrader 5
要添加评论,请登录注册
在市场中发布程序并把它销售到数百万交易者手中!
gunn
6
gunn 2012.05.28 05:41 

如题,想用脚本实现自动导出MT4账户的交易记录文件,txt或者csv都可以。然后可以统计分类,画图分析账户的盈亏情况,交易品种,做单频率等等!

应该可以实现,对mt4的函数和指令还不太熟悉,望高手不吝指点!

wang
3
wang 2012.05.30 11:07  

我用过 51jmw.net

168856243
21
168856243 2012.06.02 14:45  

简单的方法 在终端里显示全部的历史记录,另存为详细结单,那是个网页文件,用浏览器打开,复制表格,粘贴到excel中,整理一下。

复杂的给你个源码自己改吧


#property copyright "http://www.168ea.com/"
#property link "http://www.168ea.com/"
#property indicator_chart_window
int SignalBS =0;
int SignalJS=0;
datetime startTime=NULL, endTime = NULL;
color SignalPriceBUY = Red;//Yellow;
int HTotal=0;
double startPrice, endprice,TakeProfit;

int init()
{
HTotal=0;
ObjectsDeleteAll();
}
int start()
{

int orders=OrdersHistoryTotal();
int i;
//历史

if (HTotal!=orders)
{

HTotal=orders;
for(i=orders-1;i>=0;i--)
{
TakeProfit=0;
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol()==Symbol() )
{


if (OrderType()==OP_BUY)
{
SignalBS =1;
startTime= OrderOpenTime();
endTime = OrderCloseTime();
startPrice= OrderOpenPrice();
endprice = OrderClosePrice();

TakeProfit=OrderProfit();

SetBS();
}
else if (OrderType( )==OP_SELL)
{
SignalBS =-1;

startTime= OrderOpenTime();
endTime = OrderCloseTime ();
startPrice= OrderOpenPrice();
endprice = OrderClosePrice ();
TakeProfit=OrderProfit();

SetBS();
}
}
}
}

//现在交易还没有没有平仓的
orders=OrdersTotal();
for(i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderSymbol()==Symbol())
{
if (OrderType( )==OP_BUY)
{
SignalJS =1;
startTime= OrderOpenTime();
startPrice= OrderOpenPrice();
SetJS();
}
else if (OrderType( )==OP_SELL)
{
SignalJS =-1;
startTime= OrderOpenTime();
startPrice= OrderOpenPrice();
SetJS();
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+

void SetJS()
{
if (SignalJS == 1)
{


if (ObjectFind("BUY SIGNAL: " + TimeToStr(startTime))==-1)
{
ObjectCreate("BUY SIGNAL: " + TimeToStr(startTime),OBJ_ARROW,0,startTime,startPrice);
ObjectSet("BUY SIGNAL: " + TimeToStr(startTime),OBJPROP_ARROWCODE,1);
ObjectSet("BUY SIGNAL: " + TimeToStr(startTime),OBJPROP_COLOR,SignalPriceBUY);
}
}
if (SignalJS == -1)
{

if (ObjectFind("SELL SIGNAL: " + TimeToStr(startTime))==-1)
{
ObjectCreate("SELL SIGNAL: " + TimeToStr(startTime),OBJ_ARROW,0,startTime,startPrice);
ObjectSet("SELL SIGNAL: " + TimeToStr(startTime),OBJPROP_ARROWCODE,1);
ObjectSet("SELL SIGNAL: " + TimeToStr(startTime),OBJPROP_COLOR,Green);
}
}
}

void SetBS()
{

string objectnameStr="";
if (SignalBS == 1)
{
objectnameStr="BUY SIGNAL: " + TimeToStr(startTime);
if (ObjectFind(objectnameStr)==-1)
{

ObjectCreate(objectnameStr,OBJ_ARROW,0,startTime,startPrice);
ObjectSet(objectnameStr,OBJPROP_ARROWCODE,1);
ObjectSet(objectnameStr,OBJPROP_COLOR,SignalPriceBUY);

}

objectnameStr="BUY : " + TimeToStr(startTime)+TimeToStr(endTime);
if (ObjectFind(objectnameStr)==-1)
{

ObjectCreate(objectnameStr,OBJ_TREND,0,startTime,startPrice,endTime,endprice);
ObjectSet(objectnameStr,OBJPROP_COLOR,SignalPriceBUY);
ObjectSet(objectnameStr,OBJPROP_RAY,false);
if (TakeProfit>=0)
{
ObjectSet(objectnameStr,OBJPROP_STYLE,STYLE_SOLID);
}
else
{
ObjectSet(objectnameStr,OBJPROP_STYLE,STYLE_DOT);
}
}

objectnameStr="BUY Close: " + TimeToStr(endTime);
if (ObjectFind(objectnameStr)==-1)
{
ObjectCreate(objectnameStr,OBJ_ARROW,0,endTime,endprice);
ObjectSet(objectnameStr,OBJPROP_ARROWCODE,3);
ObjectSet(objectnameStr,OBJPROP_COLOR,Tan);
}
}
if (SignalBS == -1)
{
objectnameStr="SELL SIGNAL: " + TimeToStr(startTime);
if (ObjectFind(objectnameStr)==-1)
{

ObjectCreate(objectnameStr,OBJ_ARROW,0,startTime,startPrice);
ObjectSet(objectnameStr,OBJPROP_ARROWCODE,1);
ObjectSet(objectnameStr,OBJPROP_COLOR,Green);
}
objectnameStr="SELL : " +TimeToStr(startTime)+ TimeToStr(endTime);
if (ObjectFind(objectnameStr)==-1)
{
ObjectCreate(objectnameStr,OBJ_TREND,0,startTime,startPrice,endTime,endprice);
ObjectSet(objectnameStr,OBJPROP_COLOR,Lime);
ObjectSet(objectnameStr,OBJPROP_RAY,false);
if (TakeProfit>=0)
{
ObjectSet(objectnameStr,OBJPROP_STYLE,STYLE_SOLID);
}
else
{
ObjectSet(objectnameStr,OBJPROP_STYLE,STYLE_DOT);
}
}
objectnameStr="SELL Close: " + TimeToStr(endTime);
if (ObjectFind(objectnameStr)==-1)
{
ObjectCreate(objectnameStr,OBJ_ARROW,0,endTime,endprice);
ObjectSet(objectnameStr,OBJPROP_ARROWCODE,3);
ObjectSet(objectnameStr,OBJPROP_COLOR,Blue);
}
}
}

int deinit()
{
ObjectsDeleteAll();
}

/
要添加评论,请登录注册