有您的持续关注
我们会做得更好

统计账号交易情况的脚本



对于一段指定时间内的交易盈亏情况,交易手数,可以用这个脚本很方便的查阅,先打开一个单独不常交易的货币对图表,然后把放在自定义指标文件夹中(统计账号交易情况的脚本.ex4)脚本加载到图表上如下图:

qw2

 

在MT4历史记录里面选择什么时间段交易情况查询,上面就会显示对应时间段。

 

qw3

MQL4源码如下:
//|                                             统计账号交易情况.mq4 |
//|                                     Copyright 2014, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

#property indicator_chart_window

extern color 颜色 = Lime;
extern int 字号 = 9;

void deinit() {
   Comment("www.125808047.com");
}

int start() {
   string name_0 = "yl";
   string name_16 = "yl0";
   string name_24 = "yl1";
   string name_32 = "yl2";
   string name_40 = "yl3";
   double ld_56 = 0;
   double ld_57 = 0;
   double ld_58 = 0;
   double ld_64 = 0;
   double ld_65 = 0;
   double ld_66 = 0;
   double ld_72 = 0;
   double ld_80 = 0;
   double ld_88 = 0;
   double ld_89 = 0;
   double ld_90 = 0;
   double ld_96 = 0;
   double ld_104 = 0;
   int li_unused_112 = 0;
   double ld_116 = 0;
   int li_52 = OrdersHistoryTotal();
   for (int pos_48 = li_52 - 1; pos_48 >= 0; pos_48--) {
      bool chenggong = OrderSelect(pos_48, SELECT_BY_POS, MODE_HISTORY);
      if (OrderType() != OP_BUY && OrderType() != OP_SELL) ld_116 += OrderProfit();
      else {
         if (TimeDay(OrderOpenTime()) == Day()) {
          ld_57 += OrderSwap();
          ld_58 += OrderCommission();
            ld_56 += OrderProfit();
            ld_96 += OrderLots();
         }
         ld_64 += OrderProfit();
          ld_65 += OrderSwap();
          ld_66 += OrderCommission();
         ld_104 += OrderLots();
      }
   }
   li_52 = OrdersTotal();
   for (pos_48 = li_52 - 1; pos_48 >= 0; pos_48--) {
      chenggong = OrderSelect(pos_48, SELECT_BY_POS);
      if (OrderSymbol() == Symbol())
      ld_89 += OrderSwap();
      ld_90 += OrderCommission();
       ld_88 += OrderProfit();
   }
   ld_72 = 100.0 * ld_56 / (AccountBalance() - ld_56);
   ld_80 = 100.0 * (ld_64+ld_65+ld_66) / (AccountBalance() - (ld_64+ld_65+ld_66));
   string text_8 = "总入金:" + DoubleToStr(ld_116, 2);
   ObjectCreate(name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name_0, text_8, 字号, "Times New Roman", 颜色);
   ObjectSet(name_0, OBJPROP_CORNER, 0);
   ObjectSet(name_0, OBJPROP_XDISTANCE, 10);
   ObjectSet(name_0, OBJPROP_YDISTANCE, 30);
   text_8 = "总盈利:" + DoubleToStr(ld_64+ld_65+ld_66, 2) + "  盈利百分比:" + DoubleToStr(ld_80, 2) + "%";
   ObjectCreate(name_16, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name_16, text_8, 字号, "Times New Roman", 颜色);
   ObjectSet(name_16, OBJPROP_CORNER, 0);
   ObjectSet(name_16, OBJPROP_XDISTANCE, 10);
   ObjectSet(name_16, OBJPROP_YDISTANCE, 50);
   text_8 = "今日盈利:" + DoubleToStr(ld_56+ld_57+ld_58, 2) + "   盈利百分比:" + DoubleToStr(ld_72, 2) + "%";
   ObjectCreate(name_24, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name_24, text_8, 字号, "Times New Roman", 颜色);
   ObjectSet(name_24, OBJPROP_CORNER, 0);
   ObjectSet(name_24, OBJPROP_XDISTANCE, 10);
   ObjectSet(name_24, OBJPROP_YDISTANCE, 70);
   text_8 = "做单总量:" + DoubleToStr(ld_104, 2) + "    今日单量:" + DoubleToStr(ld_96, 2);
   ObjectCreate(name_40, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name_40, text_8, 字号, "Times New Roman", 颜色);
   ObjectSet(name_40, OBJPROP_CORNER, 0);
   ObjectSet(name_40, OBJPROP_XDISTANCE, 10);
   ObjectSet(name_40, OBJPROP_YDISTANCE, 90);
   text_8 = "现有单盈利:" + DoubleToStr(ld_88+ld_89+ld_90, 2);
   ObjectCreate(name_32, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(name_32, text_8, 字号, "Times New Roman", 颜色);
   ObjectSet(name_32, OBJPROP_CORNER, 0);
   ObjectSet(name_32, OBJPROP_XDISTANCE, 10);
   ObjectSet(name_32, OBJPROP_YDISTANCE, 110);  
   
   return (0);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 统计账号交易情况的脚本
上一篇:
下一篇:
分享到:更多 ()

评论 抢沙发

评论前必须登录!