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

智能交易系统 Calypso ver 1.04 EA



Calypso ver 1.04 EA一款来自俄罗斯人开发的加码EA。这次整理直接将源码中杂乱的乱码去掉了,不影响交易策略的东西,随便它怎么提示去。

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

//+------------------------------------------------------------------+
//|                                             Calypso ver 1.04.mq4 |
//|                                     Copyright 2014, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

double gd_108 = 0.01;
extern double Dinamic_lot = 10.0;
extern bool lv_mode = FALSE;
extern int Level_stop = 0;
extern bool sm_mode = FALSE;
extern int stop = 25;
extern int sn_mode = 50;
extern int sh_mode = 50;
extern bool st_mode = TRUE;
extern double sk_mode = 2.0;
extern bool sr_mode = TRUE;
int gi_unused_220 = 0;
int g_magic_224 = 59999;
int gi_228 = 24;
int g_pos_232;
datetime g_time_236;
string g_symbol_240;
double g_ima_248;
double g_ima_256;
double gd_264;
bool cg = false;


void SetLab(string a_name_0, int a_x_8, int a_y_12, int a_corner_16, string a_text_20, int a_fontsize_28, string a_fontname_32, color a_color_40 = -1) {
   ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12);
   ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_16);
   ObjectSetText(a_name_0, a_text_20, a_fontsize_28, a_fontname_32, a_color_40);
}

double setpoint() {
   double ld_ret_0;
   if (Digits <= 3) ld_ret_0 = 0.01;
   else ld_ret_0 = 0.0001;
   return (ld_ret_0);
}

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


int start() {
   double ld_0;
   double ld_8;
   double l_ord_open_price_16;
   double l_ord_open_price_24;
   double l_minlot_32;
   double l_marginrequired_40;
   double ld_48;
   int li_56;
   double ld_60;
   int l_count_68;
   bool li_72;
   bool li_76;
   int l_count_80;
   int l_count_84;
   int l_count_88;
   double ld_92;
   double l_minlot_100;
   double ld_108;
   double ld_116;
   double ld_124;
   double ld_132;
   int l_error_140;
   int li_144;
   string ls_148;
   string ls_156;
   string ls_164;
   string ls_172;
   HideTestIndicators(TRUE);
   g_ima_256 = iMA(Symbol(), 0, 3, 0, MODE_LWMA, PRICE_MEDIAN, 0);
   g_ima_248 = iMA(Symbol(), 0, 3, 0, MODE_LWMA, PRICE_MEDIAN, 1);
   HideTestIndicators(FALSE);
   if (IsTradeAllowed()) {
      if (Time[0] == g_time_236) return (0);
      g_time_236 = Time[0];
      g_symbol_240 = Symbol();
      ld_0 = NormalizeDouble(Ask, Digits);
      ld_8 = NormalizeDouble(Bid, Digits);
      l_ord_open_price_16 = 0;
      l_ord_open_price_24 = 0;
      l_minlot_32 = MarketInfo(g_symbol_240, MODE_MINLOT);
      l_marginrequired_40 = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
      ld_48 = l_minlot_32;
      for (double ld_180 = 0; ld_48 < 1.0; ld_180++) ld_48 = 10.0 * ld_48;
      li_56 = OrdersTotal() - 1;
      if (lv_mode == TRUE) {
         if (AccountBalance() - AccountBalance() * Level_stop / 100.0 > AccountEquity()) {
            for (int l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
                cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
               if (OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
                  if (OrderType() == OP_BUY) CloseBuy();
                  if (OrderType() == OP_SELL) CloseSell();
               }
            }
         }
      }
      ld_60 = 0;
      l_count_68 = 0;
      li_72 = TRUE;
      li_76 = TRUE;
      for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
          cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
         if (OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) l_count_68++;
      }
      if (l_count_68 >= sn_mode) li_72 = FALSE;
      l_count_80 = 0;
      l_count_84 = 0;
      l_count_88 = 0;
      ld_92 = gd_108;
      l_minlot_100 = gd_108;
      ld_108 = 0;
      ld_116 = 0;
      ld_124 = 0;
      for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
          cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
            ld_60 = OrderProfit() + OrderSwap() + ld_60;
            ld_108 += OrderLots();
            l_ord_open_price_16 = OrderOpenPrice();
            l_count_88++;
            if (MathAbs(l_ord_open_price_16 - ld_0) < sh_mode * setpoint()) l_count_80++;
            if (l_ord_open_price_16 - ld_0 > sh_mode * setpoint()) l_count_84++;
            if (ld_0 < l_ord_open_price_16) ld_116++;
            if (OrderLots() > ld_92) ld_92 = OrderLots();
         }
      }
      ld_108 /= 2.0;
      if (l_count_80 != 0) li_76 = FALSE;
      ld_92 = l_minlot_32;
      if (l_count_88 == 0) {
         l_minlot_100 = NormalizeDouble(AccountFreeMargin() * Dinamic_lot / 1000.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED), ld_180);
         if (l_minlot_100 < l_minlot_32) l_minlot_100 = l_minlot_32;
      }
      if (l_count_84 == l_count_88 && l_count_88 != 0 && ld_116 == l_count_88) {
         if (st_mode == TRUE) {
            for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
                cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
               if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240)
                  if (OrderLots() > ld_92) ld_92 = OrderLots();
            }
            l_minlot_100 = NormalizeDouble(ld_92 * sk_mode, ld_180);
         }
      }
      if (ld_60 >= l_marginrequired_40 * ld_108) {
         li_56 = OrdersTotal() - 1;
         for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
             cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
            RefreshRates();
            if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
               if (IsTesting() || IsOptimization())  cg = OrderClose(OrderTicket(), OrderLots(), MarketInfo(g_symbol_240, MODE_BID), 3, Blue);
               else CloseBuy();
            }
         }
      }
      if (sr_mode == FALSE) gd_264 = iHighest(g_symbol_240, 0, MODE_HIGH, gi_228, 0);
      else gd_264 = iLowest(g_symbol_240, 0, MODE_LOW, gi_228, 0);
      if ((gd_264 == 1.0 || gd_264 == 2.0 || gd_264 == 3.0) && g_ima_256 > g_ima_248 && li_72 == TRUE && li_76 == TRUE) {
         RefreshRates();
         if (IsTesting() || IsOptimization())  cg = OrderSend(g_symbol_240, OP_BUY, l_minlot_100, NormalizeDouble(MarketInfo(g_symbol_240, MODE_ASK), Digits), 3, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Blue);
         else OpenBuy(g_symbol_240, l_minlot_100);
      }
      ld_132 = 0;
      li_76 = TRUE;
      l_count_80 = 0;
      l_count_84 = 0;
      l_count_88 = 0;
      ld_92 = gd_108;
      l_minlot_100 = gd_108;
      ld_60 = 0;
      li_56 = OrdersTotal() - 1;
      for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
          cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
            ld_60 = OrderProfit() + OrderSwap() + ld_60;
            ld_132 += OrderLots();
            l_ord_open_price_24 = OrderOpenPrice();
            l_count_88++;
            if (MathAbs(l_ord_open_price_24 - ld_8) < sh_mode * setpoint()) l_count_80++;
            if (ld_8 - l_ord_open_price_24 > sh_mode * setpoint()) l_count_84++;
            if (ld_8 > l_ord_open_price_24) ld_124++;
            if (OrderLots() > ld_92) ld_92 = OrderLots();
         }
      }
      ld_132 /= 2.0;
      if (l_count_80 != 0) li_76 = FALSE;
      ld_92 = l_minlot_32;
      if (l_count_88 == 0) {
         l_minlot_100 = NormalizeDouble(AccountFreeMargin() * Dinamic_lot / 1000.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED), ld_180);
         if (l_minlot_100 < l_minlot_32) l_minlot_100 = l_minlot_32;
      }
      if (l_count_84 == l_count_88 && l_count_88 != 0 && ld_124 == l_count_88) {
         if (st_mode == TRUE) {
            for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
                cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
               if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240)
                  if (OrderLots() > ld_92) ld_92 = OrderLots();
            }
            l_minlot_100 = NormalizeDouble(ld_92 * sk_mode, ld_180);
         }
      }
      if (ld_60 >= l_marginrequired_40 * ld_132) {
         li_56 = OrdersTotal() - 1;
         for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
             cg = OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
            RefreshRates();
            if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
               if (IsTesting() || IsOptimization())  cg = OrderClose(OrderTicket(), OrderLots(), MarketInfo(g_symbol_240, MODE_ASK), 3, Fuchsia);
               else CloseSell();
            }
         }
      }
      if (sr_mode == FALSE) gd_264 = iLowest(g_symbol_240, 0, MODE_LOW, gi_228, 0);
      else gd_264 = iHighest(g_symbol_240, 0, MODE_HIGH, gi_228, 0);
      if ((gd_264 == 1.0 || gd_264 == 2.0 || gd_264 == 3.0) && g_ima_256 < g_ima_248 && li_72 == TRUE && li_76 == TRUE) {
         RefreshRates();
         if (IsTesting() || IsOptimization())  cg = OrderSend(g_symbol_240, OP_SELL, l_minlot_100, NormalizeDouble(MarketInfo(g_symbol_240, MODE_BID), Digits), 3, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Fuchsia);
         else OpenSell(g_symbol_240, l_minlot_100);
      }
      g_symbol_240 = Symbol();
      l_error_140 = 0;
      if (sm_mode == TRUE) {
         if (stop < MarketInfo(g_symbol_240, MODE_STOPLEVEL)) stop = MarketInfo(g_symbol_240, MODE_STOPLEVEL);
         for (g_pos_232 = 0; g_pos_232 <= OrdersTotal() - 1; g_pos_232++) {
             cg = OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES);
            if (OrderMagicNumber() == g_magic_224 && OrderStopLoss() == 0.0 && OrderSymbol() == Symbol()) {
               while (li_144 <= 10) {
                   cg = OrderModify(OrderTicket(), 0, MarketInfo(g_symbol_240, MODE_ASK) - stop * setpoint(), 0, 0, C'0x02,0x00,0x00');
                  l_error_140 = GetLastError();
                  if (l_error_140 == 0/* NO_ERROR */) {
                    
                     break;
                  }
                  RefreshRates();
                  Sleep(5000);
                  li_144++;
               }
              
               return (l_error_140);
            }
         }
      }
   } 
   
   return (0);
}

int OpenBuy(string a_symbol_0, double a_lots_8) {
   int l_ticket_16;
   int l_slippage_20;
   int li_24 = 1;
   while (true) {
      l_slippage_20 = 1;
      l_ticket_16 = OrderSend(a_symbol_0, OP_BUY, a_lots_8, NormalizeDouble(MarketInfo(a_symbol_0, MODE_ASK), Digits), l_slippage_20, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Blue);
      if (l_ticket_16 <= 0) {
         while (RefreshRates() == FALSE) Sleep(5000);
         li_24++;
         if (li_24 % 5 == 0) l_slippage_20++;
      } else {
         break;
      }
      if (li_24 != 11) continue;
      break;
   }
   return (0);
}

int OpenSell(string a_symbol_0, double a_lots_8) {
   int l_ticket_16;
   int l_slippage_20;
   int li_24 = 1;
   while (true) {
      l_slippage_20 = 1;
      l_ticket_16 = OrderSend(a_symbol_0, OP_SELL, a_lots_8, NormalizeDouble(MarketInfo(a_symbol_0, MODE_BID), Digits), l_slippage_20, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Fuchsia);
      if (l_ticket_16 <= 0) {
         while (RefreshRates() == FALSE) Sleep(5000);
         li_24++;
         if (li_24 % 5 == 0) l_slippage_20++;
      } else {
         break;
      }
      if (li_24 != 11) continue;
      break;
   }
   return (0);
}

void CloseBuy() {
   int l_error_0;
   int l_count_4 = 0;
   while (true) {
       cg = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID), Digits), 2, White);
      l_error_0 = GetLastError();
      if (l_error_0 == 0/* NO_ERROR */) {
        
         return;
      }
     
      Sleep(500);
      RefreshRates();
      l_count_4++;
      if (l_count_4 <= 25) continue;
      break;
   }
   Alert("Order failed to CLOSE - See Journal for errors");
}

void CloseSell() {
   int l_error_0;
   int l_count_4 = 0;
   while (true) {
       cg = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK), Digits), 2, Red);
      l_error_0 = GetLastError();
      if (l_error_0 == 0/* NO_ERROR */) {
         
         return;
      }
      
      Sleep(500);
      RefreshRates();
      l_count_4++;
      if (l_count_4 <= 25) continue;
      break;
   }
   Alert("Order failed to CLOSE - See Journal for errors");
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 智能交易系统 Calypso ver 1.04 EA
上一篇:
下一篇:
分享到:更多 ()