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

MT4复盘脚本



MT4复盘方式很多种,这里提供一种最简洁的复盘脚本,首先在账号历史选定要复盘的时间段及交易品种,然后双击脚本到图表,就会显示出订单的开仓平仓点。方便更详细的总结进出场技巧。

如图所示:

MT4复盘脚本MQL4源码如下:

//+------------------------------------------------------------------+
//|                                                     复盘脚本.mq4 |
//|                                     Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "Copyright @2016, 125808047"
#property link      "http://www.125808047.com"

int gi_76 = 0;
int g_datetime_80 = 0;
int g_datetime_84 = 0;
int g_color_88 = DeepPink;
int g_color_92 = DeepSkyBlue;
double g_order_open_price_96;
double g_price_104;

int start() {
   int hist_total_0 = OrdersHistoryTotal();
   Print("Ord=", hist_total_0);
   for (int pos_4 = hist_total_0 - 1; pos_4 >= 0; pos_4--) {
      if (OrderSelect(pos_4, SELECT_BY_POS, MODE_HISTORY) == TRUE) {
         if (OrderType() == OP_BUY) {
            gi_76 = 1;
            g_datetime_80 = OrderOpenTime();
            g_datetime_84 = OrderCloseTime();
            g_order_open_price_96 = OrderOpenPrice();
            g_price_104 = OrderClosePrice();
            SetBS();
            continue;
         }
         if (OrderType() == OP_SELL) {
            gi_76 = -1;
            g_datetime_80 = OrderOpenTime();
            g_datetime_84 = OrderCloseTime();
            g_order_open_price_96 = OrderOpenPrice();
            g_price_104 = OrderClosePrice();
            SetBS();
         }
      }
   }
   return (0);
}

void SetBS() {
   if (gi_76 == 1) {
      ObjectDelete("BUY SIGNAL: " + TimeToStr(g_datetime_80));
      ObjectDelete("BUY : " + TimeToStr(g_datetime_84));
      ObjectDelete("BUY Close: " + TimeToStr(g_datetime_84));
      ObjectCreate("BUY SIGNAL: " + TimeToStr(g_datetime_80), OBJ_ARROW, 0, g_datetime_80, g_order_open_price_96);
      ObjectSet("BUY SIGNAL: " + TimeToStr(g_datetime_80), OBJPROP_ARROWCODE, 1);
      ObjectSet("BUY SIGNAL: " + TimeToStr(g_datetime_80), OBJPROP_COLOR, g_color_88);
      ObjectCreate("BUY : " + TimeToStr(g_datetime_84), OBJ_TREND, 0, g_datetime_80, g_order_open_price_96, 
g_datetime_84, g_price_104);
      ObjectSet("BUY : " + TimeToStr(g_datetime_84), OBJPROP_COLOR, g_color_88);
      ObjectSet("BUY : " + TimeToStr(g_datetime_84), OBJPROP_RAY, FALSE);
      ObjectSet("BUY : " + TimeToStr(g_datetime_84), OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("BUY Close: " + TimeToStr(g_datetime_84), OBJ_ARROW, 0, g_datetime_84, g_price_104);
      ObjectSet("BUY Close: " + TimeToStr(g_datetime_84), OBJPROP_ARROWCODE, 3);
      ObjectSet("BUY Close: " + TimeToStr(g_datetime_84), OBJPROP_COLOR, Red);
   }
   if (gi_76 == -1) {
      ObjectDelete("SELL SIGNAL: " + TimeToStr(g_datetime_80));
      ObjectDelete("SELL : " + TimeToStr(g_datetime_84));
      ObjectDelete("SELL Close: " + TimeToStr(g_datetime_84));
      ObjectCreate("SELL SIGNAL: " + TimeToStr(g_datetime_80), OBJ_ARROW, 0, g_datetime_80, g_order_open_price_96);
      ObjectSet("SELL SIGNAL: " + TimeToStr(g_datetime_80), OBJPROP_ARROWCODE, 1);
      ObjectSet("SELL SIGNAL: " + TimeToStr(g_datetime_80), OBJPROP_COLOR, g_color_92);
      ObjectCreate("SELL : " + TimeToStr(g_datetime_84), OBJ_TREND, 0, g_datetime_80, g_order_open_price_96, 
g_datetime_84, g_price_104);
      ObjectSet("SELL : " + TimeToStr(g_datetime_84), OBJPROP_COLOR, g_color_92);
      ObjectSet("SELL : " + TimeToStr(g_datetime_84), OBJPROP_RAY, FALSE);
      ObjectSet("SELL : " + TimeToStr(g_datetime_84), OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("SELL Close: " + TimeToStr(g_datetime_84), OBJ_ARROW, 0, g_datetime_84, g_price_104);
      ObjectSet("SELL Close: " + TimeToStr(g_datetime_84), OBJPROP_ARROWCODE, 3);
      ObjectSet("SELL Close: " + TimeToStr(g_datetime_84), OBJPROP_COLOR, RoyalBlue);
   }
}
如您喜欢此文章请点下面分享按钮↴峰汇在线 » MT4复盘脚本
上一篇:
下一篇:
分享到:更多 ()