诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4 EA > 正文

根据鳄鱼线Alligator及AO、AC信号开发的EA hoper_c.mq4

hoper_c EA根据鳄鱼线Alligator及AO、AC信号在自动交易。

源码:

//+------------------------------------------------------------------+
//|                                                      hoper_c.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com"

bool gi_76 = TRUE;
bool gi_80 = TRUE;
bool gi_84 = TRUE;
bool gi_88 = TRUE;
double g_lots_92 = 0.1;
extern double 每单交易量 = 0.1;
double gd_108 = 0.0;
double gd_116 = 0.0;
double gd_unused_124 = 0.0;
extern double 上行止赢价位 = 0.0;
extern double 下行止赢价位 = 0.0;
int gi_unused_148 = 0;
int gi_152 = 0;
bool gi_unused_156 = FALSE;
bool gi_unused_160 = FALSE;
bool gi_164 = FALSE;
bool gi_168 = FALSE;
bool g_bool_172 = TRUE;
extern bool 允许连续执行 = TRUE;
int gi_180 = 100;
extern int 交易单间距点差 = 100;
extern int 最大持仓量 = 4;
extern int 止赢点数 = 0;
int gi_196;
int gi_200;
int g_slippage_204 = 10;
bool g_bars_208;
int gi_212;
int gi_unused_216;
int gi_220;
int gi_224;
int gi_228;
int gi_232;
double gd_248;
double gd_256;
double gd_264;
double gd_272;
int gi_304;
int gi_308;
int gi_312;
bool gi_316;
bool cg = TRUE;

int OnInit(void)
{
   gi_212 = 0;
   gi_unused_216 = 1;
   gi_316 = FALSE;
   g_bars_208 = FALSE;
   g_lots_92 = 每单交易量;
   gd_108 = 上行止赢价位;
   gd_116 = 下行止赢价位;
   gd_unused_124 = 0;
   gi_unused_148 = gi_152;
   gi_unused_156 = gi_164;
   gi_unused_160 = gi_168;
   g_bool_172 = 允许连续执行;
   gi_196 = 交易单间距点差;
   gi_304 = 最大持仓量;
   gi_308 = 止赢点数;
   gi_312 = getDirection();
   gi_200 = gi_180;
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}

void OnTick() 
{
   int l_ord_total_0;
   int li_8 = 1299278351;
   switch (gi_212) {
   case 0:
      dowait();
      break;
   case 1:
      dorunning();
      break;
   case 2:
      l_ord_total_0 = OrdersTotal();
      if (l_ord_total_0 > 0) {
         for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) {
            cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() == Symbol()) {
               closeorders();
               if (gi_316) Print("止赢平仓");
            }
         }
      }
      break;
   case 3:
      l_ord_total_0 = OrdersTotal();
      if (l_ord_total_0 > 0) {
         for (l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) {
            cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() == Symbol()) {
               if (gi_316) Print("止损平仓");
               closeorders();
            }
         }
      }
      if (g_bool_172) {
         cleansignal();
         gi_212 = 0;
      }
   }
}

int closeorders() {
   int l_error_8;
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) {
      cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderType() == OP_BUY) {
            cg = OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_204, CLR_NONE);
            l_error_8 = GetLastError();
            if (l_error_8 > 1/* NO_RESULT */) Print("Error message on close buy order , error : ", l_error_8);
         } else {
            if (OrderType() == OP_SELL) {
               cg = OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_204, CLR_NONE);
               l_error_8 = GetLastError();
               if (l_error_8 > 1/* NO_RESULT */) Print("Error message on close sell order , error : ", l_error_8);
            }
         }
      }
   }
   return (0);
}

int closeBackOrder(int ai_0) {
   int l_error_12;
   bool l_cmd_16;
   if (!findStartFR(ai_0)) return (0);
   if (ai_0 == 0) l_cmd_16 = FALSE;
   else l_cmd_16 = TRUE;
   int l_count_20 = 0;
   int l_ord_total_4 = OrdersTotal();
   if (l_ord_total_4 > 0) {
      for (int l_pos_8 = l_ord_total_4 - 1; l_pos_8 >= 0; l_pos_8--) {
         cg = OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderType() == l_cmd_16) l_count_20++;
      }
   }
   if (l_count_20 == 0) return (0);
   l_ord_total_4 = OrdersTotal();
   for (l_pos_8 = l_ord_total_4 - 1; l_pos_8 >= 0; l_pos_8--) {
      cg = OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
      if (ai_0 == 0) {
         if (OrderSymbol() == Symbol()) {
            if (OrderType() == OP_SELL) {
               if (gi_316) Print("平反向交易单");
               cg = OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_204, CLR_NONE);
               l_error_12 = GetLastError();
               if (l_error_12 > 1/* NO_RESULT */) Print("平卖单失败, 错误号: ", l_error_12);
            }
         }
      } else {
         if (ai_0 == 1) {
            if (OrderSymbol() == Symbol()) {
               if (OrderType() == OP_BUY) {
                  if (gi_316) Print("平反向交易单");
                  cg = OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_204, CLR_NONE);
                  l_error_12 = GetLastError();
                  if (l_error_12 > 1/* NO_RESULT */) Print("平买单失败 , 错误号: ", l_error_12);
               }
            }
         }
      }
   }
   return (0);
}

int ModifyStopProfit(int ai_0) {
   int l_ord_total_20;
   int l_error_28;
   double l_price_4 = getStopLossPrice(ai_0);
   double l_price_12 = getTakeProfitPrice(ai_0);
   if (ai_0 == 0) {
      l_ord_total_20 = OrdersTotal();
      if (l_ord_total_20 > 0) {
         for (int l_pos_24 = l_ord_total_20 - 1; l_pos_24 >= 0; l_pos_24--) {
            cg = OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && (OrderStopLoss() != l_price_4 || OrderTakeProfit() != l_price_12)) {
               if (gi_308 > 0) l_price_12 = OrderOpenPrice() + Point * gi_308;
               if (l_price_12 > Ask + 100.0 * Point) cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_4, l_price_12, 0, CLR_NONE);
               else cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_4, OrderTakeProfit(), 0, CLR_NONE);
               l_error_28 = GetLastError();
               if (l_error_28 > 1/* NO_RESULT */) Print("Error message on modify buy order , error : ", l_error_28);
            }
         }
      }
   } else {
      l_ord_total_20 = OrdersTotal();
      if (l_ord_total_20 > 0) {
         for (l_pos_24 = l_ord_total_20 - 1; l_pos_24 >= 0; l_pos_24--) {
            cg = OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && (OrderStopLoss() != l_price_4 || OrderTakeProfit() != l_price_12)) {
               if (gi_308 > 0) l_price_12 = OrderOpenPrice() - Point * gi_308;
               if (l_price_12 < Bid - 100.0 * Point) cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_4, l_price_12, 0, CLR_NONE);
               else cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_4, OrderTakeProfit(), 0, CLR_NONE);
               l_error_28 = GetLastError();
               if (l_error_28 > 1/* NO_RESULT */) Print("Error message on modify sell order , error : ", l_error_28);
            }
         }
      }
   }
   return (1);
}

void dowait() {
   gi_212 = 1;
}

int getDirection() {
   bool li_ret_0;
   int li_unused_24 = 0;
   int li_unused_28 = 1;
   double l_ialligator_8 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);
   if (Bid > l_ialligator_8) li_ret_0 = FALSE;
   else li_ret_0 = TRUE;
   return (li_ret_0);
}

bool findStartFR(int ai_0) {
   bool li_36 = FALSE;
   double l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);
   int li_8 = 0;
   if (ai_0 == 0) {
      if (Low[0] < l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1);
      if (Low[1] < l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 2);
      if (Low[2] < l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 3);
      if (Low[3] < l_ialligator_12) li_36 = TRUE;
      li_8 = 3;
      while (true) {
         if (iFractals(NULL, 0, MODE_UPPER, li_8) > 0.0 && iFractals(NULL, 0, MODE_UPPER, li_8) > l_ialligator_12) {
            if (li_36) {
               if (iFractals(NULL, 0, MODE_UPPER, li_8) < iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, li_8, 0))) return (TRUE);
               return (FALSE);
            }
            if (iFractals(NULL, 0, MODE_UPPER, li_8) < iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, li_8, 0))) return (TRUE);
         }
         li_8++;
         l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8);
         if (Low[li_8] >= l_ialligator_12) continue;
         li_36 = TRUE;
      }
   }
   if (ai_0 == 1) {
      if (High[0] > l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1);
      if (High[1] > l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 2);
      if (High[2] > l_ialligator_12) li_36 = TRUE;
      l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 3);
      if (High[3] > l_ialligator_12) li_36 = TRUE;
      li_8 = 3;
      while (true) {
         if (iFractals(NULL, 0, MODE_LOWER, li_8) > 0.0 && iFractals(NULL, 0, MODE_LOWER, li_8) < l_ialligator_12) {
            if (li_36) {
               if (iFractals(NULL, 0, MODE_LOWER, li_8) > iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, li_8, 0))) return (TRUE);
               return (FALSE);
            }
            if (iFractals(NULL, 0, MODE_LOWER, li_8) > iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, li_8, 0))) return (TRUE);
         }
         li_8++;
         l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8);
         if (High[li_8] <= l_ialligator_12) continue;
         li_36 = TRUE;
      }
   }
   return (FALSE);
}

bool mySendOrder(int a_cmd_0, int a_magic_4, string a_comment_8) {
   int l_error_16;
   if (a_cmd_0 == OP_BUY) {
      if (gi_316) cg = OrderSend(Symbol(), a_cmd_0, g_lots_92, Ask, g_slippage_204, 0, 0, a_comment_8, a_magic_4, 0, MediumBlue);
      else cg = OrderSend(Symbol(), a_cmd_0, g_lots_92, Ask, g_slippage_204, 0, 0, "order by hoper", a_magic_4, 0, CLR_NONE);
      l_error_16 = GetLastError();
      if (l_error_16 > 1/* NO_RESULT */) Print("Error message on ", a_comment_8, ", buy, ErrorCode:", l_error_16);
   } else {
      if (gi_316) cg = OrderSend(Symbol(), a_cmd_0, g_lots_92, Bid, g_slippage_204, 0, 0, a_comment_8, a_magic_4, 0, FireBrick);
      else cg = OrderSend(Symbol(), a_cmd_0, g_lots_92, Bid, g_slippage_204, 0, 0, "order by hoper", a_magic_4, 0, CLR_NONE);
      l_error_16 = GetLastError();
      if (l_error_16 > 1/* NO_RESULT */) Print("Error message on ", a_comment_8, ", sell, ErrorCode:", l_error_16);
   }
   return (FALSE);
}

double getStopLossPrice(int ai_0) {
   double ld_ret_4;
   double ld_12;
   int l_ord_total_44;
   int li_48;
   int l_count_52;
   double l_ialligator_28 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);
   double l_isar_36 = iSAR(NULL, 0, 0.01, 0.2, 0);
   if (ai_0 == 0) {
      li_48 = 3;
      for (l_ialligator_28 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_48); iFractals(NULL, 0, MODE_LOWER, li_48) == 0.0 || iFractals(NULL, 0, MODE_LOWER, li_48) > l_ialligator_28; l_ialligator_28 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_48)) li_48++;
      ld_ret_4 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, li_48 + 1, 0));
      if (ld_ret_4 < l_isar_36 && Bid > l_isar_36) ld_ret_4 = l_isar_36;
   } else {
      if (ai_0 == 1) {
         li_48 = 3;
         for (l_ialligator_28 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_48); iFractals(NULL, 0, MODE_UPPER, li_48) == 0.0 || iFractals(NULL, 0, MODE_UPPER, li_48) < l_ialligator_28; l_ialligator_28 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_48)) li_48++;
         ld_ret_4 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, li_48 + 1, 0));
         if (ld_ret_4 > l_isar_36 && Bid < l_isar_36) ld_ret_4 = l_isar_36;
         ld_ret_4 = ld_ret_4 + Ask - Bid;
      }
   }
   if (ai_0 == 0) {
      l_ord_total_44 = OrdersTotal();
      if (l_ord_total_44 > 0) {
         for (li_48 = 0; li_48 < l_ord_total_44; li_48++) {
            cg = OrderSelect(li_48, SELECT_BY_POS, MODE_TRADES);
            if (ld_ret_4 < OrderStopLoss() && OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderStopLoss() > 0.0) ld_ret_4 = OrderStopLoss();
         }
      }
   } else {
      if (ai_0 == 1) {
         l_ord_total_44 = OrdersTotal();
         if (l_ord_total_44 > 0) {
            for (li_48 = 0; li_48 < l_ord_total_44; li_48++) {
               cg = OrderSelect(li_48, SELECT_BY_POS, MODE_TRADES);
               if (ld_ret_4 > OrderStopLoss() && OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderStopLoss() > 0.0) ld_ret_4 = OrderStopLoss();
            }
         }
      }
   }
   if (ai_0 == 0) {
      l_ord_total_44 = OrdersTotal();
      ld_12 = 0;
      l_count_52 = 0;
      if (l_ord_total_44 > 0) {
         for (li_48 = 0; li_48 < l_ord_total_44; li_48++) {
            cg = OrderSelect(li_48, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() == Symbol() && OrderType() == OP_BUY) {
               ld_12 += (Bid - OrderOpenPrice()) / Point;
               l_count_52++;
            }
         }
      }
      Comment("盈利点数:" + DoubleToStr(ld_12, 0));
   } else {
      if (ai_0 == 1) {
         l_ord_total_44 = OrdersTotal();
         ld_12 = 0;
         l_count_52 = 0;
         if (l_ord_total_44 > 0) {
            for (li_48 = 0; li_48 < l_ord_total_44; li_48++) {
               cg = OrderSelect(li_48, SELECT_BY_POS, MODE_TRADES);
               if (OrderSymbol() == Symbol() && OrderType() == OP_SELL) {
                  ld_12 += (OrderOpenPrice() - Ask) / Point;
                  l_count_52++;
               }
            }
         }
         Comment("盈利点数:" + DoubleToStr(ld_12, 0));
      }
   }
   return (ld_ret_4);
}

double getTakeProfitPrice(int ai_0) {
   if (ai_0 == 0) {
      if (!(gd_108 != 0.0 && gd_108 > Ask)) return (0);
      return (gd_108);
   }
   if (ai_0 == 1)
      if (gd_116 != 0.0 && gd_116 < Bid) return (gd_116);
   return (0);
}

void dorunning() {
   double ld_20;
   int li_0 = getDirection();
   if (gi_312 != li_0) {
      gi_312 = li_0;
      g_bars_208 = FALSE;
   }
   closeBackOrder(li_0);
   if (li_0 == 0) {
      ld_20 = getTakeProfitPrice(0);
      if (Bid >= ld_20 && ld_20 != 0.0) {
         gi_212 = 2;
         gi_unused_216 = 1;
         return;
      }
   } else {
      if (li_0 == 1) {
         ld_20 = getTakeProfitPrice(1);
         if (Ask <= ld_20 && ld_20 != 0.0) {
            gi_212 = 2;
            gi_unused_216 = 1;
            return;
         }
      }
   }
   if (li_0 == 0) {
      if (Bid <= getStopLossPrice(0)) {
         gi_212 = 3;
         return;
      }
      ModifyStopProfit(0);
   } else {
      if (li_0 == 1) {
         if (Ask >= getStopLossPrice(1)) {
            gi_212 = 3;
            return;
         }
         ModifyStopProfit(1);
      }
   }
   if (g_bars_208 != Bars) {
      g_bars_208 = Bars;
      if (li_0 == 0) {
         getAOSignal(li_0);
         getACSignal(li_0);
         getFRSignal(li_0);
         getBLSignal(li_0);
      } else {
         if (li_0 == 1) {
            getAOSignal(li_0);
            getACSignal(li_0);
            getFRSignal(li_0);
            getBLSignal(li_0);
         }
      }
      if (gi_316)
         if (gd_256 != 0.0) Print("AO信号棒:", TimeToStr(gi_224, TIME_DATE|TIME_MINUTES), " 信号价格:", gd_256);
      if (gi_316)
         if (gd_264 != 0.0) Print("AC信号棒:", TimeToStr(gi_228, TIME_DATE|TIME_MINUTES), " 信号价格:", gd_264);
      if (gi_316)
         if (gd_272 != 0.0) Print("BL信号棒:", TimeToStr(gi_232, TIME_DATE|TIME_MINUTES), " 信号价格:", gd_272);
      if (gi_316)
         if (gd_248 != 0.0) Print("FR信号棒:", TimeToStr(gi_220, TIME_DATE|TIME_MINUTES), " 信号价格:", gd_248);
   }
   if (li_0 == 0) {
      if (haveOrder(gi_220, gd_248, OP_BUY)) {
         gi_220 = 0;
         gd_248 = 0;
      } else {
         if (iHigh(NULL, 0, 0) > gd_248 && gd_248 > 0.0 && gi_88 && Bid < gd_248 + gi_200 * Point) {
            if (mySendOrder(OP_BUY, gi_220, "fr" + TimeToStr(gi_220, TIME_DATE|TIME_MINUTES))) {
               gi_220 = 0;
               gd_248 = 0;
            }
         }
      }
      if (findStartFR(li_0)) {
         if (haveOrder(gi_232, gd_272, OP_BUY)) {
            gi_232 = 0;
            gd_272 = 0;
         } else {
            if (iHigh(NULL, 0, 0) > gd_272 && gd_272 > 0.0 && gi_84 && Bid < gd_272 + gi_200 * Point) {
               if (mySendOrder(OP_BUY, gi_232, "bl" + TimeToStr(gi_232, TIME_DATE|TIME_MINUTES))) {
                  gi_232 = 0;
                  gd_272 = 0;
               }
            }
         }
         if (haveOrder(gi_224, gd_256, OP_BUY)) {
            gi_224 = 0;
            gd_256 = 0;
         } else {
            if (iHigh(NULL, 0, 0) > gd_256 && gd_256 > 0.0 && gi_76 && Bid < gd_256 + gi_200 * Point) {
               if (mySendOrder(OP_BUY, gi_224, "ao" + TimeToStr(gi_224, TIME_DATE|TIME_MINUTES))) {
                  gi_224 = 0;
                  gd_256 = 0;
               }
            }
         }
         if (haveOrder(gi_228, gd_264, OP_BUY)) {
            gi_228 = 0;
            gd_264 = 0;
         } else {
            if (iHigh(NULL, 0, 0) > gd_264 && gd_264 > 0.0 && gi_80 && Bid < gd_264 + gi_200 * Point) {
               if (mySendOrder(OP_BUY, gi_228, "ac" + TimeToStr(gi_228, TIME_DATE|TIME_MINUTES))) {
                  gi_228 = 0;
                  gd_264 = 0;
               }
            }
         }
      }
   } else {
      if (li_0 == 1) {
         if (haveOrder(gi_220, gd_248, OP_SELL)) {
            gi_220 = 0;
            gd_248 = 0;
         } else {
            if (iLow(NULL, 0, 0) < gd_248 && gi_88 && Bid > gd_248 - gi_200 * Point) {
               if (mySendOrder(OP_SELL, gi_220, "fr" + TimeToStr(gi_220, TIME_DATE|TIME_MINUTES))) {
                  gi_220 = 0;
                  gd_248 = 0;
               }
            }
         }
         if (findStartFR(li_0)) {
            if (haveOrder(gi_232, gd_272, OP_SELL)) {
               gi_232 = 0;
               gd_272 = 0;
            } else {
               if (iLow(NULL, 0, 0) < gd_272 && gi_84 && Bid > gd_272 - gi_200 * Point) {
                  if (mySendOrder(OP_SELL, gi_232, "bl" + TimeToStr(gi_232, TIME_DATE|TIME_MINUTES))) {
                     gi_232 = 0;
                     gd_272 = 0;
                  }
               }
            }
            if (haveOrder(gi_224, gd_256, OP_SELL)) {
               gi_224 = 0;
               gd_256 = 0;
            } else {
               if (iLow(NULL, 0, 0) < gd_256 && gi_76 && Bid > gd_256 - gi_200 * Point) {
                  if (mySendOrder(OP_SELL, gi_224, "ao " + TimeToStr(gi_224, TIME_DATE|TIME_MINUTES))) {
                     gi_224 = 0;
                     gd_256 = 0;
                  }
               }
            }
            if (haveOrder(gi_228, gd_264, OP_SELL)) {
               gi_228 = 0;
               gd_264 = 0;
            } else {
               if (iLow(NULL, 0, 0) < gd_264 && gi_80 && Bid > gd_264 - gi_200 * Point) {
                  if (mySendOrder(OP_SELL, gi_228, "ac " + TimeToStr(gi_228, TIME_DATE|TIME_MINUTES))) {
                     gi_228 = 0;
                     gd_264 = 0;
                  }
               }
            }
         }
      }
   }
}

void cleansignal() {
   gi_220 = 0;
   gi_224 = 0;
   gi_228 = 0;
   gi_232 = 0;
   gd_248 = 0;
   gd_256 = 0;
   gd_264 = 0;
   gd_272 = 0;
}

void getAOSignal(int ai_0) {
   if (ai_0 == 0) {
      if (gd_256 > 0.0 && gi_224 == iTime(NULL, 0, 2) && iAO(NULL, 0, 1) > iAO(NULL, 0, 2) && iHigh(NULL, 0, 1) < iHigh(NULL, 0, 2)) {
         gi_224 = iTime(NULL, 0, 1);
         gd_256 = iHigh(NULL, 0, 1);
         return;
      }
      gd_256 = 0;
      gi_224 = iTime(NULL, 0, 1);
      if (iAO(NULL, 0, 1) > iAO(NULL, 0, 2) && iAO(NULL, 0, 3) > iAO(NULL, 0, 2) && iAO(NULL, 0, 2) > 0.0) {
         gd_256 = iHigh(NULL, 0, 1);
         return;
      }
      if (iAO(NULL, 0, 1) > 0.0 && iAO(NULL, 0, 2) < 0.0) {
         gd_256 = iHigh(NULL, 0, 1);
         return;
      }
      if (!(iAO(NULL, 0, 1) > iAO(NULL, 0, 2) && iAO(NULL, 0, 3) > iAO(NULL, 0, 2) && iAO(NULL, 0, 3) < 0.0 && iAO(NULL, 0, 1) < 0.0)) return;
      for (int li_4 = 2; (iAO(NULL, 0, li_4 + 1) < iAO(NULL, 0, li_4 + 2) || iAO(NULL, 0, li_4 + 3) < iAO(NULL, 0, li_4 + 2)) && iAO(NULL, 0, li_4 + 3) < 0.0 && iAO(NULL, 0, li_4 +
         1) < 0.0 && iAO(NULL, 0, li_4 + 2) < 0.0; li_4++) {
      }
      if (!(iAO(NULL, 0, li_4 + 3) < 0.0 && iAO(NULL, 0, li_4 + 1) < 0.0 && iAO(NULL, 0, li_4 + 2) < 0.0 && iAO(NULL, 0, li_4 + 2) < iAO(NULL, 0, 2))) return;
      gd_256 = iHigh(NULL, 0, 1);
      return;
   }
   if (ai_0 == 1) {
      if (gd_256 > 0.0 && gi_224 == iTime(NULL, 0, 2) && iAO(NULL, 0, 1) < iAO(NULL, 0, 2) && iLow(NULL, 0, 1) > iLow(NULL, 0, 2)) {
         gi_224 = iTime(NULL, 0, 1);
         gd_256 = iLow(NULL, 0, 1);
         return;
      }
      gd_256 = 0;
      gi_224 = iTime(NULL, 0, 1);
      if (iAO(NULL, 0, 1) < iAO(NULL, 0, 2) && iAO(NULL, 0, 3) < iAO(NULL, 0, 2) && iAO(NULL, 0, 2) < 0.0) {
         gd_256 = iLow(NULL, 0, 1);
         return;
      }
      if (iAO(NULL, 0, 1) < 0.0 && iAO(NULL, 0, 2) > 0.0) {
         gd_256 = iLow(NULL, 0, 1);
         return;
      }
      if (iAO(NULL, 0, 1) < iAO(NULL, 0, 2) && iAO(NULL, 0, 3) < iAO(NULL, 0, 2) && iAO(NULL, 0, 3) > 0.0 && iAO(NULL, 0, 1) < 0.0) {
         for (li_4 = 2; (iAO(NULL, 0, li_4 + 1) > iAO(NULL, 0, li_4 + 2) || iAO(NULL, 0, li_4 + 3) > iAO(NULL, 0, li_4 + 2)) && iAO(NULL, 0, li_4 + 3) > 0.0 && iAO(NULL, 0, li_4 +
            1) > 0.0 && iAO(NULL, 0, li_4 + 2) > 0.0; li_4++) {
         }
         if (iAO(NULL, 0, li_4 + 3) > 0.0 && iAO(NULL, 0, li_4 + 1) > 0.0 && iAO(NULL, 0, li_4 + 2) > 0.0 && iAO(NULL, 0, li_4 + 2) > iAO(NULL, 0, 2)) gd_256 = iLow(NULL, 0, 1);
      }
   }
}

void getACSignal(int ai_0) {
   if (ai_0 == 0) {
      if (gd_264 > 0.0 && gi_228 == iTime(NULL, 0, 2) && iAC(NULL, 0, 1) > iAC(NULL, 0, 2) && iHigh(NULL, 0, 1) < iHigh(NULL, 0, 2)) {
         gi_228 = iTime(NULL, 0, 1);
         gd_264 = iHigh(NULL, 0, 1);
         return;
      }
      gd_264 = 0;
      gi_228 = iTime(NULL, 0, 1);
      if (iAC(NULL, 0, 1) < 0.0 && iAC(NULL, 0, 1) > iAC(NULL, 0, 2) && iAC(NULL, 0, 2) > iAC(NULL, 0, 3) && iAC(NULL, 0, 3) > iAC(NULL, 0, 4) && iAC(NULL, 0, 4) < iAC(NULL, 0, 5)) {
         gd_264 = iHigh(NULL, 0, 1);
         return;
      }
      if (iAC(NULL, 0, 1) > 0.0 && iAC(NULL, 0, 2) < 0.0 && iAC(NULL, 0, 1) > iAC(NULL, 0, 2) && iAC(NULL, 0, 2) > iAC(NULL, 0, 3) && iAC(NULL, 0, 3) > iAC(NULL, 0, 4) &&
         iAC(NULL, 0, 4) < iAC(NULL, 0, 5)) {
         gd_264 = iHigh(NULL, 0, 1);
         return;
      }
      if (iAC(NULL, 0, 1) > 0.0 && iAC(NULL, 0, 2) < 0.0 && iAC(NULL, 0, 1) > iAC(NULL, 0, 2) && iAC(NULL, 0, 2) > iAC(NULL, 0, 3) && iAC(NULL, 0, 3) < iAC(NULL, 0, 4)) {
         gd_264 = iHigh(NULL, 0, 1);
         return;
      }
      if (!(iAC(NULL, 0, 1) > 0.0 && iAC(NULL, 0, 2) > 0.0 && iAC(NULL, 0, 1) > iAC(NULL, 0, 2) && iAC(NULL, 0, 2) > iAC(NULL, 0, 3) && iAC(NULL, 0, 3) < iAC(NULL, 0, 4))) return;
      gd_264 = iHigh(NULL, 0, 1);
      return;
   }
   if (ai_0 == 1) {
      if (gd_264 > 0.0 && gi_228 == iTime(NULL, 0, 2) && iAC(NULL, 0, 1) < iAC(NULL, 0, 2) && iLow(NULL, 0, 1) > iLow(NULL, 0, 2)) {
         gi_228 = iTime(NULL, 0, 1);
         gd_264 = iLow(NULL, 0, 1);
         return;
      }
      gd_264 = 0;
      gi_228 = iTime(NULL, 0, 1);
      if (iAC(NULL, 0, 1) > 0.0 && iAC(NULL, 0, 1) < iAC(NULL, 0, 2) && iAC(NULL, 0, 2) < iAC(NULL, 0, 3) && iAC(NULL, 0, 3) < iAC(NULL, 0, 4) && iAC(NULL, 0, 4) > iAC(NULL, 0, 5)) {
         gd_264 = iLow(NULL, 0, 1);
         return;
      }
      if (iAC(NULL, 0, 1) < 0.0 && iAC(NULL, 0, 2) > 0.0 && iAC(NULL, 0, 1) < iAC(NULL, 0, 2) && iAC(NULL, 0, 2) < iAC(NULL, 0, 3) && iAC(NULL, 0, 3) < iAC(NULL, 0, 4) &&
         iAC(NULL, 0, 4) > iAC(NULL, 0, 5)) {
         gd_264 = iLow(NULL, 0, 1);
         return;
      }
      if (iAC(NULL, 0, 1) < 0.0 && iAC(NULL, 0, 2) > 0.0 && iAC(NULL, 0, 1) < iAC(NULL, 0, 2) && iAC(NULL, 0, 2) < iAC(NULL, 0, 3) && iAC(NULL, 0, 3) > iAC(NULL, 0, 4)) {
         gd_264 = iLow(NULL, 0, 1);
         return;
      }
      if (iAC(NULL, 0, 1) < 0.0 && iAC(NULL, 0, 2) < 0.0 && iAC(NULL, 0, 1) < iAC(NULL, 0, 2) && iAC(NULL, 0, 2) < iAC(NULL, 0, 3) && iAC(NULL, 0, 3) > iAC(NULL, 0, 4)) gd_264 = iLow(NULL, 0, 1);
   }
}

void getFRSignal(int ai_0) {
   int li_8;
   gi_220 = 0;
   gd_248 = 0;
   if (ai_0 == 0) {
      li_8 = 3;
      for (double l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8); iFractals(NULL, 0, MODE_UPPER, li_8) == 0.0 ||
         iFractals(NULL, 0, MODE_UPPER, li_8) < l_ialligator_12; l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8)) li_8++;
      if (iFractals(NULL, 0, MODE_UPPER, li_8) == 0.0) return;
      if (iFractals(NULL, 0, MODE_UPPER, li_8) >= l_ialligator_12 && iFractals(NULL, 0, MODE_UPPER, li_8) > iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, li_8 - 1, 1))) {
         gi_220 = iTime(NULL, 0, li_8);
         gd_248 = iHigh(NULL, 0, li_8);
         return;
      }
      gi_220 = 0;
      gd_248 = 0;
      return;
   }
   if (ai_0 == 1) {
      li_8 = 3;
      for (l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8); iFractals(NULL, 0, MODE_LOWER, li_8) == 0.0 || iFractals(NULL, 0, MODE_LOWER, li_8) > l_ialligator_12; l_ialligator_12 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_8)) li_8++;
      if (iFractals(NULL, 0, MODE_LOWER, li_8) != 0.0) {
         if (iFractals(NULL, 0, MODE_LOWER, li_8) <= l_ialligator_12 && iFractals(NULL, 0, MODE_LOWER, li_8) < iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, li_8 - 1, 1))) {
            gi_220 = iTime(NULL, 0, li_8);
            gd_248 = iLow(NULL, 0, li_8);
            return;
         }
         gi_220 = 0;
         gd_248 = 0;
      }
   }
}

void getBLSignal(int ai_0) {
   int li_4;
   int l_count_12;
   int li_16;
   double ld_28;
   gd_272 = 0;
   gi_232 = 0;
   double l_ialligator_20 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 0);
   double l_ialligator_36 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1);
   int li_8 = 1;
   if (ai_0 == 0) {
      if (Bid < l_ialligator_20) li_8 = 2;
      if (iAO(NULL, 0, 1) < iAO(NULL, 0, 2) && iAC(NULL, 0, 1) < iAC(NULL, 0, 2)) li_8 *= 2;
      li_4 = 1;
      while (iHigh(NULL, 0, li_4) > iHigh(NULL, 0, li_4 + 1) && iClose(NULL, 0, li_4) > l_ialligator_36) {
         li_4++;
         l_ialligator_36 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_4);
      }
      if (!(iHigh(NULL, 0, li_4) < iHigh(NULL, 0, li_4 + 1) && iClose(NULL, 0, li_4) > l_ialligator_36)) return;
      l_count_12 = 0;
      li_16 = 1;
      ld_28 = iHigh(NULL, 0, li_4);
      while (l_count_12 < li_8 && iHigh(NULL, 0, li_4 + li_16) > l_ialligator_36) {
         if (iHigh(NULL, 0, li_4 + li_16) > ld_28) {
            l_count_12++;
            ld_28 = iHigh(NULL, 0, li_4 + li_16);
         }
         li_16++;
      }
      if (!(l_count_12 == li_8 && ld_28 >= iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, li_4, 1)))) return;
      gd_272 = ld_28;
      gi_232 = iTime(NULL, 0, li_4 + li_16 - 1);
      return;
   }
   if (ai_0 == 1) {
      if (Bid > l_ialligator_20) li_8 = 2;
      if (iAO(NULL, 0, 1) > iAO(NULL, 0, 2) && iAC(NULL, 0, 1) > iAC(NULL, 0, 2)) li_8 *= 2;
      li_4 = 1;
      while (iLow(NULL, 0, li_4) < iLow(NULL, 0, li_4 + 1) && iClose(NULL, 0, li_4) < l_ialligator_36) {
         li_4++;
         l_ialligator_36 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, li_4);
      }
      if (iLow(NULL, 0, li_4) > iLow(NULL, 0, li_4 + 1) && iClose(NULL, 0, li_4) < l_ialligator_36) {
         l_count_12 = 0;
         li_16 = 1;
         ld_28 = iLow(NULL, 0, li_4);
         while (l_count_12 < li_8 && iLow(NULL, 0, li_4 + li_16) < l_ialligator_36) {
            if (iLow(NULL, 0, li_4 + li_16) < ld_28) {
               l_count_12++;
               ld_28 = iLow(NULL, 0, li_4 + li_16);
            }
            li_16++;
         }
         if (l_count_12 == li_8 && ld_28 <= iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, li_4, 1))) {
            gd_272 = ld_28;
            gi_232 = iTime(NULL, 0, li_4 + li_16 - 1);
         }
      }
   }
}

bool haveOrder(int a_magic_0, double ad_4, int a_cmd_12) {
   int li_24;
   int l_count_28 = 0;
   int li_16 = OrdersTotal();
   if (li_16 > 100) li_24 = li_16 - 100;
   else li_24 = 0;
   if (li_16 > 0) {
      for (int l_pos_20 = li_16 - 1; l_pos_20 >= 0; l_pos_20--) {
         cg = OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderType() == a_cmd_12) l_count_28++;
         if (OrderSymbol() == Symbol() && OrderType() == a_cmd_12 && OrderMagicNumber() == a_magic_0) return (TRUE);
         if (a_cmd_12 == OP_BUY) {
            if (!(OrderSymbol() == Symbol() && OrderType() == a_cmd_12 && MathAbs(OrderOpenPrice() - Ask + Bid - ad_4) / Point < gi_196)) continue;
            return (TRUE);
         }
         if (a_cmd_12 == OP_SELL)
            if (OrderSymbol() == Symbol() && OrderType() == a_cmd_12 && MathAbs(OrderOpenPrice() - ad_4) / Point < gi_196) return (TRUE);
      }
   }
   li_16 = OrdersHistoryTotal();
   if (li_16 > 0) {
      for (l_pos_20 = li_16 - 1; l_pos_20 >= li_24; l_pos_20--) {
         cg = OrderSelect(l_pos_20, SELECT_BY_POS, MODE_HISTORY);
         if (OrderSymbol() == Symbol() && OrderType() == a_cmd_12 && OrderMagicNumber() == a_magic_0) return (TRUE);
      }
   }
   if (l_count_28 >= gi_304) return (TRUE);
   return (FALSE);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 根据鳄鱼线Alligator及AO、AC信号开发的EA hoper_c.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏