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

智能交易系统SteadyWinner V5.0



SteadyWinner V5.0EA曾经测试过,单量偏少,在编程方面还是有值得参考的地方。

本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。 SteadyWinner V5.0EA源码如下:

//+------------------------------------------------------------------+
//|                                            SteadyWinner V5.0.mq4 |
//|                                       Copyright @2015, 125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link  "http://www.125808047.com"

string gs_unused_76 = "SteadyWinner V5.0";
int g_acc_number_84 = 0;
double gd_88;
double gd_96;
double gd_104;
double gd_112;
double gd_120;
double gd_128;
double gd_136;
double gd_144;
double gd_152 = 900.0;
double gd_160 = 3600.0;
extern string NoteSpread = "Max Spreads: 2.0 - 4.0";
extern double MaxSpread = 4.0;
extern bool   MoneyManagement = True;
extern double PercentRisk     = 5.0;
extern double LotSize         = 0.1;
extern string NoteFri = "Trade after Friday Cut Hour";
extern bool   TradeLateFri = FALSE;
extern int    FridayCutHour = 15;
extern string NoteDec = "Trade on December Cut Date (15)";
int gi_208 = 15;
extern bool   TradeLateDec = FALSE;
extern string NoteBroker = "Broker Friendly Settings";
extern bool   PipStepping = FALSE;
extern bool   FXOpenECN = FALSE;
extern string NoteEA = "Magic No.& Comments, pls change it";
extern int    MagicNo = 338833;
extern string CommentTxt = "SW-V5";
string gs_unused_252 = "Professional Settings";
double gd_260 = 110.0;
double gd_268 = 55.0;
double gd_276 = 22.0;
double gd_284 = 5.0;
double gd_292 = 0.0;
double g_lots_300 = 0.1;
double gd_308 = 0.0;
double gd_324;
double gd_316;
double gd_332;
double g_order_profit_340 = 0.0;
double gd_348 = 0.0;
double g_maxlot_356 = 0.0;
double g_lotstep_364 = 0.0;
double gd_372 = 0.0;
int g_slippage_380 = 3;
bool gi_384 = TRUE;
int gi_388 = 0;
int gi_392 = 23;
int gi_396 = -1;
bool gi_400 = TRUE;
string gs_404 = "alert.wav";
int g_color_412 = Blue;
int g_color_416 = Aqua;
int g_color_420 = Red;
int g_color_424 = Aqua;
string gs_unused_428 = "0";
string gs_dummy_436;
string g_text_444 = "Smart MM finds nothing wrong.";
int g_color_452 = LightGreen;

void init() {
   string ls_60;
   string ls_68;
   string ls_76;
   string ls_84;
   MaxSpread = f0_5(MaxSpread, 2.0, 4.0, 1);
   FridayCutHour = f0_5(FridayCutHour, 0, 23, 0);
   gd_88 = gd_260;
   gd_96 = gd_260;
   gd_104 = gd_268;
   gd_112 = gd_268;
   gd_120 = gd_276;
   gd_128 = gd_276;
   gd_136 = gd_284;
   gd_144 = gd_284;
   if (PipStepping) gd_292 = 1;
   gd_372 = f0_6(Symbol());
   f0_4();
   int li_0 = 20;
   int li_4 = 40;
   int li_8 = 60;
   int li_12 = 80;
   int li_16 = 100;
   int li_20 = 120;
   int li_24 = 140;
   int li_28 = 160;
   int li_32 = 180;
   int li_36 = 200;
   int li_40 = 220;
   int li_44 = 240;
   int li_48 = 10;
   int li_52 = 200;
   int li_56 = 380;
   f0_8("Title1", li_0 - 5, li_48, "SteadyWinner V5.0 - Place on EURUSD(H1) ", 13, "Verdana", MediumSeaGreen);
   f0_8("Title2", li_4, li_48, "http://www.125808047.com", 9, "Verdana", White);
   f0_8("Line1a", li_8, li_48, "---------------------------", 10, "Verdana", Goldenrod);
   f0_8("Line1b", li_8, li_52, "--- EA Settings ------------------------------", 10, "Verdana", Goldenrod);
   f0_8("txtRisk", li_12, li_48, "Trade Lot Risk%:  " + DoubleToStr(PercentRisk, 1), 9, "Verdana", Gold);
   f0_8("txtScale", li_12, li_52, "Test Lot Scale:     " + DoubleToStr(PercentRisk, 1), 9, "Verdana", Gold);
   f0_8("txtMaxSpread", li_12, li_56, "Max Spread:    " + DoubleToStr(MaxSpread, 1), 9, "Verdana", Gold);
   f0_8("TxtTradeLots", li_16, li_48, "Trade Lot Size:     " + DoubleToStr(gd_316, 2), 9, "Verdana", Gold);
   f0_8("TxtTestLots", li_16, li_52, "Test Lot Size:       " + DoubleToStr(gd_324, 2), 9, "Verdana", Gold);
   f0_8("TxtCurSpread", li_16, li_56, "Now Spread:   " + DoubleToStr(gd_332, 1), 9, "Verdana", Gold);
   f0_8("TxtMaxLot", li_20, li_48, "Max Lots:             " + DoubleToStr(g_maxlot_356, 2), 9, "Verdana", Silver);
   f0_8("TxtMinLot", li_20, li_52, "Min Lots:              " + DoubleToStr(gd_348, 2), 9, "Verdana", Silver);
   f0_8("TxtLotStep", li_20, li_56, "Lot Step:         " + DoubleToStr(g_lotstep_364, 2), 9, "Verdana", Silver);
   f0_8("TxtSL", li_24, li_48, "Stop Loss:           " + DoubleToStr(gd_260, 0), 9, "Verdana", Silver);
   f0_8("TxtTP", li_24, li_52, "Take Profit:          " + DoubleToStr(gd_268, 0), 9, "Verdana", Silver);
   f0_8("TxtTS", li_28, li_48, "Trailing Stop:       " + DoubleToStr(gd_276, 0), 9, "Verdana", Silver);
   f0_8("TxtTR", li_28, li_52, "Trailing Reserve:  " + DoubleToStr(gd_284, 0), 9, "Verdana", Silver);
   if (TradeLateFri) ls_60 = "Trade after Friday " + DoubleToStr(FridayCutHour, 0) + ":00:        TEST LOT ONLY";
   else ls_60 = "Trade after Friday " + DoubleToStr(FridayCutHour, 0) + ":00:        NO";
   f0_8("TxtFri", li_32, li_48, ls_60, 9, "Verdana", Gold);
   if (PipStepping) ls_76 = "YES";
   else ls_76 = "NO";
   f0_8("TxtPipStepping", li_32, li_56, "Pip Stepping:  " + ls_76, 9, "Verdana", Gold);
   if (TradeLateDec) ls_68 = "Trade after December " + DoubleToStr(gi_208, 0) + "th:    TEST LOT ONLY";
   else ls_68 = "Trade after December " + DoubleToStr(gi_208, 0) + "th:    NO";
   f0_8("TxtDec", li_36, li_48, ls_68, 9, "Verdana", Gold);
   if (FXOpenECN) ls_84 = "YES";
   else ls_84 = "NO";
   f0_8("TxtFXOpenECN", li_36, li_56, "FXOpen ECN:  " + ls_84, 9, "Verdana", Gold);
   f0_8("Line2a", li_40, li_48, "---------------------------", 10, "Verdana", Goldenrod);
   f0_8("Line2b", li_40, li_52, "---------------------------------------------", 10, "Verdana", Goldenrod);
   f0_8("TxtSmartMM", li_44, li_48, g_text_444, 9, "Verdana", g_color_452);
}

void deinit() {
   ObjectDelete("Title1");
   ObjectDelete("Title2");
   ObjectDelete("Line1a");
   ObjectDelete("Line1b");
   ObjectDelete("TxtRisk");
   ObjectDelete("TxtScale");
   ObjectDelete("TxtMaxSpread");
   ObjectDelete("TxtTradeLots");
   ObjectDelete("TxtTestLots");
   ObjectDelete("TxtCurSpread");
   ObjectDelete("TxtMaxLot");
   ObjectDelete("TxtMinLot");
   ObjectDelete("TxtLotStep");
   ObjectDelete("TxtSL");
   ObjectDelete("TxtTP");
   ObjectDelete("TxtTS");
   ObjectDelete("TxtTR");
   ObjectDelete("TxtFri");
   ObjectDelete("TxtPipStepping");
   ObjectDelete("TxtDec");
   ObjectDelete("TxtFXOpenECN");
   ObjectDelete("Line2a");
   ObjectDelete("Line2b");
   ObjectDelete("TxtSmartMM");
}

int start() {
   int is_closed_128;
   int is_closed_132;
   bool li_140;
   f0_4();
   ObjectSetText("TxtTradeLots", "Trade Lot Size:     " + DoubleToStr(LotSize, 2), 9, "Verdana", Gold);
   ObjectSetText("TxtTestLots", "Test Lot Size:       " + DoubleToStr(gd_324, 2), 9, "Verdana", Gold);
   ObjectSetText("TxtCurSpread", "Now Spread:   " + DoubleToStr(gd_332, 1), 9, "Verdana", Gold);
   ObjectSetText("TxtSmartMM", g_text_444, 9, "Verdana", g_color_452);
   if (gi_384) {
      if (!(Hour() >= gi_388 && Hour() <= gi_392)) {
         Comment("Time for trade has not come else!");
         return (0);
      }
   }
   if (Bars < 100) {
      Print("bars less than 100");
      return (0);
   }
   if (g_acc_number_84 > 0 && g_acc_number_84 != AccountNumber()) {
      Comment("Trade on account :" + AccountNumber() + " FORBIDDEN!");
      return (0);
   }
   double ima_0 = iMA(NULL, PERIOD_M15, 50, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_8 = iMA(NULL, PERIOD_M15, 100, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_16 = iMA(NULL, PERIOD_M15, 200, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_24 = iMA(NULL, PERIOD_M15, 300, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_32 = iMA(NULL, PERIOD_M15, 400, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_40 = iMA(NULL, PERIOD_M15, 500, 0, MODE_EMA, PRICE_CLOSE, 0);
   double iwpr_48 = iWPR(NULL, PERIOD_H1, 5, 0);
   double imfi_56 = iMFI(NULL, PERIOD_M30, 1, 0);
   double iclose_64 = iClose(NULL, PERIOD_M1, 0);
   double ima_72 = iMA(NULL, PERIOD_M1, 700, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_80 = iMA(NULL, PERIOD_M5, 700, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_88 = iMA(NULL, PERIOD_M15, 700, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_96 = iMA(NULL, PERIOD_M30, 700, 0, MODE_EMA, PRICE_CLOSE, 0);
   double iac_104 = iAC(NULL, PERIOD_M1, 0);
   bool bool_112 = FALSE;
   bool bool_116 = FALSE;
   bool bool_120 = FALSE;
   bool bool_124 = FALSE;
   if (!f0_0()) {
      if (g_order_profit_340 >= 0.0) {
         bool_112 = iac_104 < 0.0 && imfi_56 < 0.1 && iwpr_48 < -99.99 && ima_72 < iclose_64 && 
ima_80 < iclose_64 && ima_88 < iclose_64 && ima_96 < iclose_64 && ima_8 > ima_16 &&
            ima_16 > ima_24 && ima_24 > ima_32 && ima_32 > ima_40;
         bool_116 = iac_104 > 0.0 && imfi_56 > 99.9 && iwpr_48 > -0.01 && ima_72 > iclose_64 && 
ima_80 > iclose_64 && ima_88 > iclose_64 && ima_96 > iclose_64 && ima_8 < ima_16 &&
            ima_16 < ima_24 && ima_24 < ima_32 && ima_32 < ima_40;
      }
      if (g_order_profit_340 < 0.0) {
         bool_112 = iac_104 < 0.0 && iwpr_48 < -50.0 && ima_8 < ima_16;
         bool_116 = iac_104 > 0.0 && iwpr_48 > -50.0 && ima_8 > ima_16;
      }
      gi_396 = -1;
      if (bool_112) {
         f0_4();
         gi_396 = 0;
         gd_308 = 0;
         f0_2();
         return (0);
      }
      if (bool_116) {
         f0_4();
         gi_396 = 0;
         gd_308 = 0;
         f0_3();
         return (0);
      }
   }
   if (f0_0()) {
      if (gi_396 < 1) {
         if (OrderProfit() >= 0.0 && TimeCurrent() - OrderOpenTime() > gd_160) {
            bool_120 = iac_104 > 0.0 && iwpr_48 > -50.0 && ima_8 > ima_16;
            bool_124 = iac_104 < 0.0 && iwpr_48 < -50.0 && ima_8 < ima_16;
         }
         if (OrderProfit() < 0.0 && TimeCurrent() - OrderOpenTime() > gd_152) {
            bool_120 = iac_104 > 0.0 && iwpr_48 > -15.0 && ima_8 > ima_16;
            bool_124 = iac_104 < 0.0 && iwpr_48 < -85.0 && ima_8 < ima_16;
         }
      }
      if (OrderType() == OP_BUY) {
         if (bool_120) {
            is_closed_128 = OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_380, g_color_416);
            if (is_closed_128 && gi_400) PlaySound(gs_404);
            return (0);
         }
      }
      if (OrderType() == OP_SELL) {
         if (bool_124) {
            is_closed_132 = OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_380, g_color_424);
            if (is_closed_132 && gi_400) PlaySound(gs_404);
            return (0);
         }
      }
   }
   if (gd_120 > 0.0 || gd_128 > 0.0) {
      for (int pos_136 = 0; pos_136 < OrdersTotal(); pos_136++) {
         if (OrderSelect(pos_136, SELECT_BY_POS, MODE_TRADES)) {
            li_140 = TRUE;
            if (MagicNo > 0 && OrderMagicNumber() != MagicNo) li_140 = FALSE;
            if (OrderSymbol() == Symbol() && li_140) {
               if (OrderType() == OP_BUY && gd_120 > 0.0) {
                  if (Bid - OrderOpenPrice() > gd_120 * gd_372) {
                     if (OrderStopLoss() < Bid - (gd_120 + gd_308) * gd_372) {
                        if (gi_396 == 0) {
                           f0_1(Bid - NormalizeDouble((gd_120 - gd_136) * gd_372, 5));
                           gi_396 = 1;
                           gd_308 = gd_292;
                        } else f0_1(Bid - NormalizeDouble(gd_120 * gd_372, 5));
                     }
                  }
               }
               if (OrderType() == OP_SELL) {
                  if (OrderOpenPrice() - Ask > gd_128 * gd_372) {
                     if (OrderStopLoss() > Ask + (gd_128 + gd_308) * gd_372 || OrderStopLoss() == 0.0) {
                        if (gi_396 == 0) {
                           f0_1(Ask + NormalizeDouble((gd_128 - gd_144) * gd_372, 5));
                           gi_396 = 1;
                           gd_308 = gd_292;
                           continue;
                        }
                        f0_1(Ask + NormalizeDouble(gd_128 * gd_372, 5));
                     }
                  }
               }
            }
         }
      }
   }
   return (0);
}

bool f0_0() {
   bool li_4;
   for (int pos_0 = 0; pos_0 < OrdersTotal(); pos_0++) {
      if (OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES)) {
         li_4 = TRUE;
         if (MagicNo > 0 && OrderMagicNumber() != MagicNo) li_4 = FALSE;
         if (OrderSymbol() == Symbol() && li_4) return (TRUE);
      }
   }
   return (FALSE);
}

void f0_1(double ad_0) {
   bool bool_8 = OrderModify(OrderTicket(), NormalizeDouble(OrderOpenPrice(), 5), NormalizeDouble(ad_0, 5), 
NormalizeDouble(OrderTakeProfit(), 5), 0, CLR_NONE);
   if (bool_8 && gi_400) PlaySound(gs_404);
}

void f0_2() {
   double price_0;
   double price_8;
   int ticket_16;
   if (g_lots_300 != 0.0) {
      price_0 = 0;
      price_8 = 0;
      ticket_16 = OrderSend(Symbol(), OP_BUY, g_lots_300, Ask, g_slippage_380, 0, 0, CommentTxt, MagicNo, 0, 
g_color_412);
      if (ticket_16 > -1) {
         OrderSelect(ticket_16, SELECT_BY_TICKET);
         if (gd_88 > 0.0) price_0 = NormalizeDouble(OrderOpenPrice() - gd_88 * gd_372, Digits);
         if (gd_104 > 0.0) price_8 = NormalizeDouble(OrderOpenPrice() + gd_104 * gd_372, Digits);
         OrderModify(OrderTicket(), OrderOpenPrice(), price_0, price_8, 0, Green);
      }
      if (ticket_16 > -1 && gi_400) PlaySound(gs_404);
   }
}

void f0_3() {
   double price_0;
   double price_8;
   int ticket_16;
   if (g_lots_300 != 0.0) {
      price_0 = 0;
      price_8 = 0;
      ticket_16 = OrderSend(Symbol(), OP_SELL, g_lots_300, Bid, g_slippage_380, 0, 0, CommentTxt, MagicNo, 0, 
g_color_420);
      if (ticket_16 > -1) {
         OrderSelect(ticket_16, SELECT_BY_TICKET);
         if (gd_96 > 0.0) price_0 = NormalizeDouble(OrderOpenPrice() + gd_96 * gd_372, Digits);
         if (gd_112 > 0.0) price_8 = NormalizeDouble(OrderOpenPrice() - gd_112 * gd_372, Digits);
         OrderModify(OrderTicket(), OrderOpenPrice(), price_0, price_8, 0, Green);
      }
      if (ticket_16 > -1 && gi_400) PlaySound(gs_404);
   }
}

void f0_4() {
   if (MoneyManagement) LotSize = (AccountEquity() * (PercentRisk) / 100) / 1000;
   gd_348  = MarketInfo(Symbol(), MODE_MINLOT);
   g_maxlot_356  = MarketInfo(Symbol(), MODE_MAXLOT);
   g_lotstep_364 = MarketInfo(Symbol(), MODE_LOTSTEP);

   if(LotSize <= gd_348 ) LotSize = gd_348;                // checking for minimum lot
   else  if(LotSize >= g_maxlot_356 ) LotSize = g_maxlot_356;          // checking for maximum lot
   else LotSize = MathFloor(LotSize / g_lotstep_364) * g_lotstep_364;  // rounding to the nearest
   LotSize = (NormalizeDouble(LotSize,2)); 
   gd_332 = f0_7(Symbol());
   if (FXOpenECN && StringFind(AccountServer(), "FXOpen-ECN", 0) >= 0) gd_348 = 0.1;
   gd_316 = LotSize;
   gd_324 = LotSize;
   g_text_444 = "Margin level is healthy, SW is running in full mode";
   g_color_452 = LightGreen;
   for (int pos_8 = OrdersHistoryTotal() - 1; pos_8 >= 0; pos_8--) {
      OrderSelect(pos_8, SELECT_BY_POS, MODE_HISTORY);
      if (OrderMagicNumber() == MagicNo) {
         g_order_profit_340 = OrderProfit();
         pos_8 = 0;
      }
   }
   if (g_order_profit_340 == 0.0) g_lots_300 = gd_324;
   if (g_order_profit_340 > 0.0) g_lots_300 = gd_316;
   if (g_order_profit_340 < 0.0) g_lots_300 = gd_324;
   if (DayOfWeek() == 5 && Hour() > FridayCutHour) {
      g_text_444 = "It\'s Friday after " + DoubleToStr(FridayCutHour, 0) + ":00, ";
      g_color_452 = Silver;
      if (!TradeLateFri) {
         g_lots_300 = 0;
         g_text_444 = g_text_444 + "SW will not open new orders";
      } else {
         g_lots_300 = gd_324;
         g_text_444 = g_text_444 + "SW will open new TestLot orders only";
      }
   }
   if (Month() == 12 && Day() > gi_208) {
      g_text_444 = "It\'s December after " + DoubleToStr(gi_208, 0) + "th, ";
      g_color_452 = Silver;
      if (!TradeLateDec) {
         g_lots_300 = 0;
         g_text_444 = g_text_444 + "SW will not open new orders";
      } else {
         g_lots_300 = gd_324;
         g_text_444 = g_text_444 + "SW will open new TestLot orders only";
      }
   }
   if (gd_332 > MaxSpread) {
      g_text_444 = "Spread is too high, SW will not open new orders";
      g_color_452 = Silver;
      g_lots_300 = 0;
   }
   if (AccountFreeMargin() < 110.0) {
      g_text_444 = "Free Margin is dangerously low, SW will not open new orders";
      g_color_452 = HotPink;
      g_lots_300 = 0;
   }
}

double f0_5(double ad_0, double ad_8, double ad_16, int ai_24) {
   double ld_ret_28 = ad_0;
   if (ld_ret_28 < ad_8) ld_ret_28 = ad_8;
   else
      if (ld_ret_28 > ad_16) ld_ret_28 = ad_16;
   NormalizeDouble(ld_ret_28, ai_24);
   return (ld_ret_28);
}

double f0_6(string a_symbol_0) {
   int digits_16 = MarketInfo(a_symbol_0, MODE_DIGITS);
   double ld_ret_8 = 0.0001;
   if (digits_16 == 2 || digits_16 == 3) ld_ret_8 = 0.01;
   return (ld_ret_8);
}

double f0_7(string a_symbol_0) {
   double ticksize_24 = MarketInfo(a_symbol_0, MODE_TICKSIZE);
   double ld_16 = f0_6(a_symbol_0);
   double ld_ret_8 = MarketInfo(a_symbol_0, MODE_SPREAD) * (ticksize_24 / ld_16);
   return (ld_ret_8);
}

void f0_8(string a_name_0, int a_y_8, int a_x_12, string a_text_16, int a_fontsize_24, string a_fontname_28,
 color a_color_36) {
   ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSet(a_name_0, OBJPROP_CORNER, 0);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_12);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_8);
   ObjectSetText(a_name_0, a_text_16, a_fontsize_24, a_fontname_28, a_color_36);
}
如您喜欢此文章请点下面分享按钮↴峰汇在线 » 智能交易系统SteadyWinner V5.0
上一篇:
下一篇:
分享到:更多 ()