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

Auto Cash Generator V1.01 EA



Auto Cash Generator V1.01 EA属于超短剥头皮类型自动交易系统。

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

//+------------------------------------------------------------------+
//|                                    Auto Cash Generator V1.01.mq4 |
//|                              Lian Feng-Auto Cash Generator V1.01 |
//+------------------------------------------------------------------+
#property copyright "Lian Feng-Auto Cash Generator V1.01"
#property link      "http://www.125808047.com/"

bool gi_unused_76 = TRUE;
int gi_80 = D'05.02.2009 17:00';
int gi_84 = 0;
extern string EmergencyExit = "=== Lian Feng-Auto Cash Generator V1.01  ===";
extern bool ShutdownPending = FALSE;
extern bool ManualShutdown = FALSE;
extern string Broker_Display_Settings = "Lian Feng-Auto Cash Generator V1.01";
extern bool UsingPipettes = FALSE;
extern bool SwitchComments = TRUE;
extern bool OrderArrows = TRUE;
extern string GeneralParameters = "==== Lian Feng-Auto Cash Generator V1.01 ===";
extern int MagicNumber = 1234;
extern int AnchorSpaceInPips = 14;
extern int GridSizeInPips = 14;
string gs_unused_144 = "=== Lian Feng-Auto Cash Generator V1.01===";
bool gi_152 = FALSE;
string gs_unused_156 = "=== Lian Feng-Auto Cash Generator V1.01A ===";
bool gi_164 = FALSE;
string gs_unused_168 = "=== Lian Feng-Auto Cash Generator V1.01r ===";
bool gi_176 = FALSE;
bool gi_180 = FALSE;
bool gi_184 = FALSE;
string gs_unused_188 = "===Lian Feng-Auto Cash Generator V1.01===";
bool gi_196 = FALSE;
string gs_200 = "00:00";
string gs_208 = "24:00";
string gs_unused_216 = "== Lian Feng-Auto Cash Generator V1.01 ==";
bool gi_224 = TRUE;
int g_timeframe_228 = PERIOD_M1;
string gs_unused_232 = "=== Lian Feng-Auto Cash Generator V1.01 ===";
bool gi_240 = FALSE;
double gd_244 = 1.06;
double gd_252 = 1.0554;
extern string FixedLotSizeSettings = "=== Lian Feng-Auto Cash Generator V1.01 ===";
extern double AnchorLots = 2.4;
extern double Level1 = 1.2;
extern double Level2 = 0.6;
extern double Level3 = 0.3;
extern double Level4_Up = 0.1;
int gi_308 = 200;
int gi_312 = 0;
int gi_316 = 0;
extern string ProfitTargetSettings = "=== Lian Feng-Auto Cash Generator V1.01 ===";
extern double EquityTarget_All = 10.0;
extern double EquityBeginTrailing = 0.0;
double gd_344 = 0.0;
double gd_352 = 0.0;
extern bool HibernateAfterEquityClose = FALSE;
extern string BreakEvenOption = "==== Lian Feng-Auto Cash Generator V1.01 ====";
extern bool SeekBreakEven = TRUE;
extern int OpenOrdersBreakEven = 2;
extern string EquityAlerts = "=== Lian Feng-Auto Cash Generator V1.01 ===";
extern bool EquityAlert = FALSE;
extern int EquityAlertLevel = -200;
extern bool PlaySoundAlert = TRUE;
extern bool DisplayPopupAlert = TRUE;
double gd_404 = 0.02;
double gd_412 = 0.2;
int g_period_420 = 3;
int g_period_424 = 5;
int gi_428 = 1;
int gi_unused_432;
int gi_unused_436;
string gs_440 = "=== Lian Feng-Auto Cash Generator V1.01 ===";
string gs_unused_448 = "Lian Feng-Auto Cash Generator V1.01";
bool gi_456 = FALSE;
double gd_460 = 0.0;
datetime g_time_468;
double gd_unused_472 = 0.0;
double gda_480[];
double gda_484[];
double gd_488;
double gd_496;
bool gi_504 = FALSE;
bool gi_508 = TRUE;

int init() {
   g_time_468 = 0;
   ArrayResize(gda_480, gi_308);
   ArrayResize(gda_484, gi_308);
   for (int l_index_0 = 0; l_index_0 < gi_308; l_index_0++) {
      if (l_index_0 == 0) {
         gda_480[l_index_0] = AnchorLots;
         gda_484[l_index_0] = AnchorLots;
      } else {
         if (l_index_0 == 1) {
            gda_480[l_index_0] = Level1;
            gda_484[l_index_0] = Level1;
         } else {
            if (l_index_0 == 2) {
               gda_480[l_index_0] = Level2;
               gda_484[l_index_0] = Level2;
            } else {
               if (l_index_0 == 3) {
                  gda_480[l_index_0] = Level3;
                  gda_484[l_index_0] = Level3;
               } else {
                  gda_480[l_index_0] = Level4_Up;
                  gda_484[l_index_0] = Level4_Up;
               }
            }
         }
      }
   }
   if (OrderArrows) {
      gi_unused_432 = 16711680;
      gi_unused_436 = 255;
   } else {
      gi_unused_432 = -1;
      gi_unused_436 = -1;
   }
   ObjectCreate("text_object", OBJ_LABEL, 0, 0, 0);
   ObjectSet("text_object", OBJPROP_XDISTANCE, 220);
   ObjectSet("text_object", OBJPROP_YDISTANCE, 0);
   ObjectSetText("text_object", "Lian Feng-Auto Cash Generator V1.01", 10, "Verdana", Yellow);
   return (0);
}

int deinit() {
 Comment("www.125808047.com");
   return (0);
}

int start() {
   double ld_0;
   if (gi_152) Obj_Label("100", "IndicatorEntry", MediumTurquoise, 680, 15);
   if (gi_164) {
      if (gi_180 == TRUE) Obj_Label("100", "AutoDirectional-Long", MediumTurquoise, 680, 15);
      if (gi_184 == TRUE) Obj_Label("100", "AutoDirectional-Short", MediumTurquoise, 680, 15);
   }
   if (gi_176) {
      if (gi_180 == TRUE) Obj_Label("100", "Manual-GoLong = true", MediumTurquoise, 680, 15);
      if (gi_184 == TRUE) Obj_Label("100", "Manual-GoShort = true", MediumTurquoise, 680, 15);
   }
   if (gi_240) Obj_Label("100", "PriceEntry", MediumTurquoise, 680, 15);
   if (gi_224) Obj_Label("100", "SREntry", MediumTurquoise, 680, 15);
   gi_508 = TRUE;
   int li_unused_8 = 0;
   int li_12 = daysBetween(TimeCurrent(), gi_80);
  /* string ls_16 = "Lian Feng-Auto Cash Generator V1.01";
   if (TimeCurrent() >= gi_80) {
      Comment(ls_16);
      Alert(ls_16);
      return (0);
   }*/
   if (li_12 < 2 && li_12 >= 0) {
      Comment("Your subscription has " + li_12 + " days remaining.");
      gi_508 = FALSE;
   }
   if (gi_84 != 0) {
      if (AccountNumber() != gi_84) {
         Alert("PF_HG EA is \registered to account # " + gi_84 
            + "\nIf this is not your registered account", 
         "\n Mobile:13325074595");
         return (0);
      }
   }
   if (EquityBeginTrailing > 0.0 && (getProfit() >= EquityBeginTrailing && !gi_456)) {
      gi_456 = TRUE;
      gd_460 = EquityBeginTrailing - gd_344;
      return (gi_456);
   }
   if (gi_456 == TRUE && getProfit() - gd_460 > gd_344) {
      gd_460 = getProfit() - gd_344;
      return (gd_460);
   }
   if (gi_456 == TRUE && getProfit() <= gd_460) {
      gi_504 = TRUE;
      gd_460 = 0;
      gi_456 = FALSE;
      gi_180 = FALSE;
      gi_184 = FALSE;
      return(0);
   }
   double ld_24 = Point;
   if (UsingPipettes == TRUE) ld_24 = Point / 0.1;
   if (subTotalTrade() > 0) {
      if (subSellAnchorPrice() > 0.0) gd_488 = (subSellAnchorPrice() - Ask) / NormalizeDouble(ld_24, Digits);
      else gd_488 = 0;
      if (subBuyAnchorPrice() > 0.0) gd_496 = (Bid - subBuyAnchorPrice()) / NormalizeDouble(ld_24, Digits);
      else gd_496 = 0;
      g_time_468 = Time[0];
      if (ShutdownPending) while (subTotalTradePend() > 0) subCloseOrder_Pending();
      if (EquityTarget_All != 0.0 && EquityTarget_All < getProfit()) {
         Comment("EquityTarget_All has been reached");
         gi_508 = FALSE;
         gi_504 = TRUE;
         gi_180 = FALSE;
         gi_184 = FALSE;
      }
      if (gd_352 != 0.0 && gd_352 < getLoss()) {
         Comment("EquityStopLoss has been reached");
         gi_508 = FALSE;
         gi_504 = TRUE;
         gi_180 = FALSE;
         gi_184 = FALSE;
      }
      if (ManualShutdown) gi_504 = TRUE;
   }
   double ld_32 = MarketInfo(Symbol(), MODE_TICKVALUE) * AnchorLots;
   if (SeekBreakEven == TRUE && getProfit() >= ld_32 && subTotalOpenBuy() >= OpenOrdersBreakEven && subTotalOpenSell() >= OpenOrdersBreakEven && OpenOrdersBreakEven != 0) {
      Comment("Attempt at breakeven profits+losses has been executed");
      gi_508 = FALSE;
      gi_504 = TRUE;
   }
   if (subTotalTrade() == 0) {
      gi_504 = FALSE;
      if (ManualShutdown) {
         Comment("ManualShutdown");
         gi_508 = FALSE;
         return (0);
      }
      if (ShutdownPending) {
         Comment("ShutdownPending");
         gi_508 = FALSE;
         return (0);
      }
      if (HibernateAfterEquityClose && g_time_468 != 0) {
         Comment("Hibernating");
         gi_508 = FALSE;
         return (0);
      }
   }
   if (gi_504) CloseAll();
   if (subTotalTrade() == 0 && gi_504 == FALSE) {
      if (longSignal()) {
         subOpenOrder(0, 0, gi_312, gda_480[0], "Anchor-" + Symbol() + MagicNumber);
         subOpenPendingOrder(5, subBuyAnchorPrice() - AnchorSpaceInPips * NormalizeDouble(ld_24, Digits), gda_480[0], "Anchor-" + Symbol() + MagicNumber);
      }
      if (shortSignal()) {
         subOpenOrder(1, 0, gi_316, gda_480[0], "Anchor-" + Symbol() + MagicNumber);
         subOpenPendingOrder(4, subSellAnchorPrice() + AnchorSpaceInPips * NormalizeDouble(ld_24, Digits), gda_480[0], "Anchor-" + Symbol() + MagicNumber);
      }
   }
   if (gi_504 == FALSE) {
      if (subBuyAnchorTotal() > 0) CheckBuyGrid();
      if (subSellAnchorTotal() > 0) CheckSellGrid();
   }
   if (gi_508 && SwitchComments == FALSE) {
      Comment(gs_440 
         + "\nTime:  " + TimeToStr(TimeCurrent(), TIME_SECONDS) 
         + "\nBalance:  $" + DoubleToStr(AccountBalance(), 2) 
         + "\nEquity Target:  $" + EquityTarget_All 
         + "\nProfit:  $" + DoubleToStr(getProfit(), 2) 
         + "\nMagic:  -> " + MagicNumber 
         + "\nOpen Buys:  ", subTotalOpenBuy(), " Open Sells:  ", subTotalOpenSell() 
         + "\nPending Buys:  ", subTotalPendBuy(), " Pending Sells:  ", subTotalPendSell() 
      + "\nEquTrail: ", gd_460);
   }
   if (gi_508 && SwitchComments == TRUE) {
      Comment("\n", gs_440, "   Magic#:  ", MagicNumber, "   Time:  " + TimeToStr(TimeCurrent(), TIME_SECONDS) 
         + "\nBalance:  $" + DoubleToStr(AccountBalance(), 2), "   Equity Target:  $" + EquityTarget_All, "   Profit:  $" + DoubleToStr(getProfit(), 2) 
         + "\nOpen Buys:  ", subTotalOpenBuy(), "  Pending Buys:  ", subTotalPendBuy(), "   Open Sells:  ", subTotalOpenSell(), "  Pending Sells:  ", subTotalPendSell() 
      + "\nEquTrail: ", gd_460);
   }
   if (EquityAlert) {
      ld_0 = getProfit();
      if (ld_0 >= EquityAlertLevel) {
         if (PlaySoundAlert == TRUE) PlaySound("alert.wav");
         if (DisplayPopupAlert == TRUE) Alert("Equity Alert ", Symbol(), ": $", ld_0);
      }
   }
   return (0);
}

void CheckBuyGrid() {
   int l_pos_0 = 0;
   int l_count_4 = 0;
   double ld_8 = 0;
   double l_ord_open_price_16 = 0;
   double ld_24 = Point;
   if (UsingPipettes == TRUE) ld_24 = Point / 0.1;
   for (l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
      bool cg = OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUYSTOP) {
         if (OrderOpenPrice() > l_ord_open_price_16) {
            l_ord_open_price_16 = OrderOpenPrice();
            ld_8 = OrderLots();
         }
         l_count_4++;
      }
   }
   if (l_count_4 == 0) {
      l_ord_open_price_16 = subBuyAnchorPrice();
      ld_8 = AnchorLots;
   }
   if (l_count_4 < 5) {
      if (ld_8 > 0.0) {
         if (ld_8 == AnchorLots) ld_8 = Level1;
         else {
            if (ld_8 == Level1) ld_8 = Level2;
            else {
               if (ld_8 == Level2) ld_8 = Level3;
               else
                  if (ld_8 == Level3) ld_8 = Level4_Up;
            }
         }
         subOpenPendingOrder(4, l_ord_open_price_16 + GridSizeInPips * NormalizeDouble(ld_24, Digits), ld_8, "Grid-" + Symbol() + MagicNumber);
      }
   }
}

void CheckSellGrid() {
   int l_pos_0 = 0;
   int l_count_4 = 0;
   double ld_8 = 0;
   double l_ord_open_price_16 = 0;
   double ld_24 = Point;
   if (UsingPipettes == TRUE) ld_24 = Point / 0.1;
   for (l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
      bool cg = OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELLSTOP) {
         if (l_ord_open_price_16 == 0.0) {
            l_ord_open_price_16 = OrderOpenPrice();
            ld_8 = OrderLots();
         } else {
            if (OrderOpenPrice() < l_ord_open_price_16) {
               l_ord_open_price_16 = OrderOpenPrice();
               ld_8 = OrderLots();
            }
         }
         l_count_4++;
      }
   }
   if (l_count_4 == 0) {
      l_ord_open_price_16 = subSellAnchorPrice();
      ld_8 = AnchorLots;
   }
   if (l_count_4 < 5) {
      if (ld_8 > 0.0) {
         if (ld_8 == AnchorLots) ld_8 = Level1;
         else {
            if (ld_8 == Level1) ld_8 = Level2;
            else {
               if (ld_8 == Level2) ld_8 = Level3;
               else
                  if (ld_8 == Level3) ld_8 = Level4_Up;
            }
         }
         subOpenPendingOrder(5, l_ord_open_price_16 - GridSizeInPips * NormalizeDouble(ld_24, Digits), ld_8, "Grid-" + Symbol() + MagicNumber);
      }
   }
}

int subTotalTrade() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subTotalTradePend() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderType() > OP_SELL && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subTotalPendBuy() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderType() == OP_BUYSTOP && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subTotalPendSell() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderType() == OP_SELLSTOP && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subTotalOpenSell() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subTotalOpenBuy() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber) l_count_0++;
   }
   return (l_count_0);
}

int subBuyAnchorTotal() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderComment() == "Anchor-" + Symbol() + MagicNumber && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)) l_count_0++;
   }
   return (l_count_0);
}

int subSellAnchorTotal() {
   int l_count_0 = 0;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderComment() == "Anchor-" + Symbol() + MagicNumber && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP)) l_count_0++;
   }
   return (l_count_0);
}

double subBuyAnchorPrice() {
   double l_ord_open_price_0;
   int li_unused_8 = 0;
   for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) {
      bool cg = OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
      if (OrderComment() == "Anchor-" + Symbol() + MagicNumber && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)) l_ord_open_price_0 = OrderOpenPrice();
   }
   return (l_ord_open_price_0);
}

double subSellAnchorPrice() {
   double l_ord_open_price_0;
   int li_unused_8 = 0;
   for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) {
      bool cg = OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
      if (OrderComment() == "Anchor-" + Symbol() + MagicNumber && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP)) l_ord_open_price_0 = OrderOpenPrice();
   }
   return (l_ord_open_price_0);
}

int subOpenOrder(int ai_0, int ai_4, int ai_8, double a_lots_12, string a_comment_20) {
   int l_ticket_28 = 0;
   int l_error_32 = 0;
   int l_count_36 = 0;
   double l_price_40 = 0;
   double l_price_48 = 0;
   double l_price_56 = 0;
   double l_price_64 = 0;
   double ld_72 = Point;
   if (UsingPipettes == TRUE) ld_72 = Point / 0.1;
   if (ai_4 != 0) {
      l_price_40 = NormalizeDouble(Ask - ai_4 * NormalizeDouble(ld_72, Digits), 4);
      l_price_56 = NormalizeDouble(Bid + ai_4 * NormalizeDouble(ld_72, Digits), 4);
   }
   if (ai_8 != 0) {
      l_price_48 = NormalizeDouble(Ask + ai_8 * NormalizeDouble(ld_72, Digits), 4);
      l_price_64 = NormalizeDouble(Bid - ai_8 * NormalizeDouble(ld_72, Digits), 4);
   }
   if (ai_0 == 0) {
      for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
         l_ticket_28 = OrderSend(Symbol(), OP_BUY, a_lots_12, Ask, 6, l_price_40, l_price_48, a_comment_20, MagicNumber, 0, Green);
         l_error_32 = GetLastError();
         if (l_error_32 == 0/* NO_ERROR */) {
            if (l_ticket_28 > 0) break;
         } else {
            if (l_error_32 == 0/* NO_ERROR */ || l_error_32 == 4/* SERVER_BUSY */ || l_error_32 == 136/* OFF_QUOTES */ || l_error_32 == 137/* BROKER_BUSY */ || l_error_32 == 138/* REQUOTE */ ||
               l_error_32 == 146/* TRADE_CONTEXT_BUSY */) Sleep(5000);
            else
               if (l_ticket_28 > 0) break;
         }
      }
   }
   if (ai_0 == 1) {
      for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
         l_ticket_28 = OrderSend(Symbol(), OP_SELL, a_lots_12, Bid, 6, l_price_56, l_price_64, a_comment_20, MagicNumber, 0, Red);
         l_error_32 = GetLastError();
         if (l_error_32 == 0/* NO_ERROR */) {
            if (l_ticket_28 > 0) break;
         } else {
            if (l_error_32 == 0/* NO_ERROR */ || l_error_32 == 4/* SERVER_BUSY */ || l_error_32 == 136/* OFF_QUOTES */ || l_error_32 == 137/* BROKER_BUSY */ || l_error_32 == 138/* REQUOTE */ ||
               l_error_32 == 146/* TRADE_CONTEXT_BUSY */) Sleep(5000);
            else
               if (l_ticket_28 > 0) break;
         }
      }
   }
   return (l_ticket_28);
}

int subOpenPendingOrder(int ai_0, double a_price_4, double a_lots_12, string a_comment_20) {
   int l_ticket_28 = 0;
   int l_error_32 = 0;
   int l_count_36 = 0;
   if (ai_0 == 4) {
      for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
         l_ticket_28 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_12, a_price_4, 6, 0, takeGenerator(Symbol(), 4, a_price_4, gi_312), a_comment_20, MagicNumber, 0, Green);
         l_error_32 = GetLastError();
         if (l_error_32 == 0/* NO_ERROR */) {
            if (l_ticket_28 > 0) break;
         } else {
            if (l_error_32 == 0/* NO_ERROR */ || l_error_32 == 4/* SERVER_BUSY */ || l_error_32 == 136/* OFF_QUOTES */ || l_error_32 == 137/* BROKER_BUSY */ || l_error_32 == 138/* REQUOTE */ ||
               l_error_32 == 146/* TRADE_CONTEXT_BUSY */) Sleep(5000);
            else
               if (l_ticket_28 > 0) break;
         }
      }
   }
   if (ai_0 == 5) {
      for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
         l_ticket_28 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_12, a_price_4, 6, 0, takeGenerator(Symbol(), 5, a_price_4, gi_316), a_comment_20, MagicNumber, 0, Red);
         l_error_32 = GetLastError();
         if (l_error_32 == 0/* NO_ERROR */) {
            if (l_ticket_28 > 0) break;
         } else {
            if (l_error_32 == 0/* NO_ERROR */ || l_error_32 == 4/* SERVER_BUSY */ || l_error_32 == 136/* OFF_QUOTES */ || l_error_32 == 137/* BROKER_BUSY */ || l_error_32 == 138/* REQUOTE */ ||
               l_error_32 == 146/* TRADE_CONTEXT_BUSY */) Sleep(5000);
            else
               if (l_ticket_28 > 0) break;
         }
      }
   }
   return (l_ticket_28);
}

int daysBetween(int ai_0, int ai_4) {
   int li_8 = ai_4 - ai_0;
   if (li_8 > 0) return (li_8 / 3600 / 24);
   else return (0);
}

double takeGenerator(string a_symbol_0, int ai_8, double ad_12, int ai_20) {
   double l_point_24 = MarketInfo(a_symbol_0, MODE_POINT);
   if (ai_20 == 0) return (0);
   switch (ai_8) {
   case 0:
   case 2:
   case 4:
      return (ad_12 + ai_20 * l_point_24);
   case 1:
   case 3:
   case 5:
      return (ad_12 - ai_20 * l_point_24);
   }
   return (0);
}

string MA_STR() {
   double l_ima_0 = iMA(NULL, 0, g_period_420, 0, MODE_SMA, PRICE_CLOSE, 0);
   double l_ima_8 = iMA(NULL, 0, g_period_424, 0, MODE_SMA, PRICE_CLOSE, 0);
   double l_ima_16 = iMA(NULL, 0, g_period_420, 0, MODE_SMA, PRICE_CLOSE, 1);
   double l_ima_24 = iMA(NULL, 0, g_period_424, 0, MODE_SMA, PRICE_CLOSE, 1);
   HideTestIndicators(TRUE);
   l_ima_0 = iMA(NULL, 0, g_period_420, 0, MODE_SMA, PRICE_CLOSE, 0);
   l_ima_8 = iMA(NULL, 0, g_period_424, 0, MODE_SMA, PRICE_CLOSE, 0);
   l_ima_16 = iMA(NULL, 0, g_period_420, 0, MODE_SMA, PRICE_CLOSE, 1);
   l_ima_24 = iMA(NULL, 0, g_period_424, 0, MODE_SMA, PRICE_CLOSE, 1);
   HideTestIndicators(FALSE);
   if (gi_152) {
      if (l_ima_0 > l_ima_8 && l_ima_16 < l_ima_24) return ("UP");
      if (l_ima_0 < l_ima_8 && l_ima_16 > l_ima_24) return ("DOWN");
   } else {
      if (gi_164 == TRUE) {
         if (l_ima_0 > l_ima_8) return ("UP");
         if (l_ima_0 < l_ima_8) return ("DOWN");
      }
   }
   return ("");
}

int sarSaysUp(int ai_0) {
   return (Close[gi_428] > iSAR(NULL, 0, gd_404, gd_412, ai_0));
}

int sarSaysDown(int ai_0) {
   return (Close[gi_428] < iSAR(NULL, 0, gd_404, gd_412, ai_0));
}

bool timesAreValid() {
   if (!gi_196) return (TRUE);
   int l_datetime_0 = TimeCurrent();
   if (StrToTime(gs_200) < l_datetime_0)
      if (StrToTime(gs_208) > l_datetime_0) return (TRUE);
   return (FALSE);
}

double getProfit() {
   double ld_ret_0 = 0;
   for (int l_ord_total_8 = OrdersTotal(); l_ord_total_8 >= 0; l_ord_total_8--) {
      if (OrderSelect(l_ord_total_8, SELECT_BY_POS, MODE_TRADES))
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) ld_ret_0 = ld_ret_0 + OrderProfit() + OrderSwap();
   }
   return (ld_ret_0);
}

double getLoss() {
   double ld_ret_0 = 0;
   for (int l_ord_total_8 = OrdersTotal(); l_ord_total_8 >= 0; l_ord_total_8--) {
      if (OrderSelect(l_ord_total_8, SELECT_BY_POS, MODE_TRADES))
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) ld_ret_0 = ld_ret_0 - OrderProfit() - OrderSwap();
   }
   return (ld_ret_0);
}

bool longSignal() {
   double l_ihigh_0 = iHigh(NULL, g_timeframe_228, 1);
   if (timesAreValid()) {
      if (gi_152)
         if (MA_STR() == "UP" && sarSaysUp(gi_428)) return (TRUE);
      if (gi_164 == TRUE) {
         if (MA_STR() == "UP" && sarSaysUp(gi_428) == 1) {
            gi_180 = TRUE;
            gi_184 = FALSE;
         }
         if (MA_STR() == "DOWN" && sarSaysDown(gi_428) == 1) {
            gi_184 = TRUE;
            gi_180 = FALSE;
         }
         if (gi_180 && !gi_184) return (TRUE);
      }
      if (gi_176 == TRUE) {
         if (gi_180 == TRUE && gi_184 == FALSE)
            if (gi_180 && !gi_184) return (TRUE);
      }
      if (gi_240 == TRUE) {
         if (Ask == gd_244) {
            gi_180 = TRUE;
            gi_184 = FALSE;
         }
         if (gi_180 && !gi_184) return (TRUE);
      }
      if (gi_224 == TRUE) {
         if (Ask > l_ihigh_0) {
            gi_180 = TRUE;
            gi_184 = FALSE;
         }
      }
      if (gi_180 && !gi_184) return (TRUE);
   }
   return (FALSE);
}

bool shortSignal() {
   double l_ilow_0 = iLow(NULL, g_timeframe_228, 1);
   if (timesAreValid()) {
      if (gi_152)
         if (MA_STR() == "DOWN" && sarSaysDown(gi_428)) return (TRUE);
      if (gi_164 == TRUE) {
         if (MA_STR() == "UP" && sarSaysUp(gi_428) == 1) {
            gi_180 = TRUE;
            gi_184 = FALSE;
         }
         if (MA_STR() == "DOWN" && sarSaysDown(gi_428) == 1) {
            gi_184 = TRUE;
            gi_180 = FALSE;
         }
         if (!gi_180 && gi_184) return (TRUE);
      }
      if (gi_176 == TRUE) {
         if (gi_184 == TRUE && gi_180 == FALSE)
            if (!gi_180 && gi_184) return (TRUE);
      }
      if (gi_240 == TRUE) {
         if (Bid == gd_252) {
            gi_180 = FALSE;
            gi_184 = TRUE;
         }
         if (!gi_180 && gi_184) return (TRUE);
      }
      if (gi_224 == TRUE) {
         if (Bid < l_ilow_0) {
            gi_180 = FALSE;
            gi_184 = TRUE;
         }
      }
      if (!gi_180 && gi_184) return (TRUE);
   }
   return (FALSE);
}

void subCloseOrder_Pending() {
   int l_ord_total_0 = 0;
   int li_unused_4 = 0;
   int li_unused_8 = 0;
   int li_unused_12 = 0;
   int li_unused_16 = 25;
   int li_unused_20 = 0;
   l_ord_total_0 = OrdersTotal();
   for (int l_pos_24 = 0; l_pos_24 <= l_ord_total_0; l_pos_24++) {
      bool cg = OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         switch (OrderType()) {
         case OP_BUYLIMIT:
         case OP_BUYSTOP:
            cg = OrderDelete(OrderTicket());
         }
      }
   }
}

void CloseAll() {
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      bool cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         if (OrderType() == OP_BUY) cg = OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
         if (OrderType() == OP_SELL) cg = OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
         if (OrderType() > OP_SELL) cg = OrderDelete(OrderTicket());
      }
   }
}

void Obj_Label(string a_name_0, string a_text_8, color a_color_16, int a_x_20, int a_y_24) {
   ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_20);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_24);
   ObjectSetText(a_name_0, a_text_8, 10, "Verdana", a_color_16);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » Auto Cash Generator V1.01 EA
上一篇:
下一篇:
分享到:更多 ()