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

智能交易系统ichi_scalper EA



ichi_scalper EA是一款专门为澳元兑美元设计的智能交易系统,用在AUDUSD五分钟,这一点在订单的注释Ichi_FX AUDUSD_5M v54中就显示出来,这款EA曾经取得不错的成绩。

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

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

extern string RiskINFO = "1 for conservative, 2 for normal, 3 for aggressive, 4 for very aggressive, 5 for extreme.";
extern int Risk = 2;
extern string ToCloseTrades = "To CLOSE ALL Trades, set the property below UseClose=True";
extern bool UseClose = FALSE;
extern string PercentageOfAccountToUseINFO = "This is the percentage (%) of the account to calculate base lot size";
extern int PercentageOfAccount = 100;
extern string MaxCapitalToRiskINFO = "To have Equity protection, set UseMaxCapitalStop=true and set MaxCapitalToRiskPercent=protect%";
extern bool UseMaxCapitalStop = FALSE;
extern double MaxCapitalToRiskPercent = 70.0;
extern string ToCloseOldTrades = "To CLOSE trades after a certain amount of time, set property UseTimeOut=true, and set MaxTradeOpenHours=number of hours";
extern bool UseTimeOut = FALSE;
extern double MaxTradeOpenHours = 48.0;
extern string gs_152 = "Set LotsDigits to number of decimal places for lots, for 0.01 lots, set to 2, for 0.1 set to 1, for 1.0 and greater set to 0";
extern double LotDigit = 2.0;
extern string gs_168 = "This property will automatically grow your account for 0.01 lot per one thousand";
extern bool useMM = TRUE;
extern string gs_180 = "This is automatically by lotSizeGrowthPer1000, set lotSizeGrowthPer1000=false to change";
extern double LotSize = 0.01;
double g_pips_196 = 300.0;
double g_pips_204 = 30.0;
double gd_212 = 60.0;
double gd_220 = 30.0;
extern double LotCoeff = 1.4;
double gd_236 = 5.0;
extern int NbTradeMax = 9;
extern bool updateSLTP = TRUE;
int gi_252 = 1;
bool gi_256 = TRUE;
double g_slippage_260 = 3.0;
double gd_268 = 10.0;
extern bool useEquityForLotSize = FALSE;
double gd_unused_280 = 0.0;
bool gi_288 = FALSE;
bool gi_292 = TRUE;
double gd_296 = 4.0;
bool gi_304 = TRUE;
bool gi_308 = FALSE;
bool gi_unused_312 = TRUE;
int gi_316 = 40;
int gi_320 = 4;
bool gi_324 = FALSE;
double gd_328 = 0.005;
double gd_336 = 0.05;
int gi_344 = 1;
int g_period_348 = 4;
double gd_352 = 4.0;
double gd_360 = 0.01;
double gd_368 = 20.0;
int gi_376 = 13;
int gi_380 = 26;
int gi_384 = 52;
int gi_388 = 1;
int gi_unused_392 = 61;
int gi_unused_396 = 2;
int gi_unused_400 = 0;
double gd_unused_404 = 0.0;
double gd_412 = 2.0;
int gi_420 = 8;
int gi_424 = 2;
int gi_428 = 0;
int gi_432 = 2;
int gi_436 = 1;
int gi_unused_440 = 0;
int gi_unused_444 = 255;
int gi_unused_448 = 16711680;
bool gi_452 = TRUE;
double gd_456 = 0.00005;
int g_magic_464 = 8885554;
double g_price_468;
double gd_476;
double gd_unused_484;
double gd_unused_492;
double g_price_500;
double g_bid_508;
double g_ask_516;
double gd_524;
double gd_532;
double gd_540;
bool gi_548;
string gs_552 = "Ichi_FX AUDUSD_5M v54";
int g_time_560 = 0;
int gi_564;
int gi_568 = 0;
double gd_572;
int g_pos_580 = 0;
int gi_584 = 0;
double gd_588 = 0.0;
bool gi_596 = FALSE;
bool gi_600 = FALSE;
bool gi_604 = FALSE;
int gi_608;
bool gi_612 = FALSE;
double gd_616 = 0.0;
int gi_unused_624 = 10;
double gd_628 = 0.0;
double gd_unused_636 = 1.0;
double gd_644 = 1.0;
double g_iatr_652 = 0.0;
double g_iatr_660 = 0.0;
double g_pips_668;
double gd_676;
double gd_684;
double gd_unused_692;
double gd_unused_700;
double gd_708;
double g_lotstep_716;
int gi_724;
int gi_728;
int g_icustom_732 = 0;
int g_icustom_736 = 0;
bool gi_740 = FALSE;
bool gi_744 = FALSE;
bool gi_unused_748 = FALSE;
int g_datetime_752 = 0;
int g_datetime_756 = 0;
double gd_760;
double gd_768;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   string ls_unused_0;
   string ls_unused_8;
   Comment("\nbalance = " + DoubleToStr(AccountBalance(), 2), 
   "\nequity = " + DoubleToStr(AccountEquity(), 2));
   if (gd_360 < MarketInfo(Symbol(), MODE_MINLOT)) gd_360 = MarketInfo(Symbol(), MODE_MINLOT);
   if (gd_368 > MarketInfo(Symbol(), MODE_MAXLOT)) gd_368 = MarketInfo(Symbol(), MODE_MAXLOT);
   if (gd_368 < gd_360) gd_368 = gd_360;
   int li_unused_16 = MathMax(MarketInfo(Symbol(), MODE_FREEZELEVEL), MarketInfo(Symbol(), MODE_STOPLEVEL));
   gd_unused_692 = AccountStopoutLevel();
   gd_unused_700 = AccountLeverage();
   gd_708 = AccountCredit();
   g_lotstep_716 = MarketInfo(Symbol(), MODE_LOTSTEP);
   gi_724 = AccountFreeMarginMode();
   gi_728 = AccountStopoutMode();
   double marginrequired_20 = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   if (gi_724 == 0) ls_unused_0 = "that floating profit/loss is not used for calculation.";
   else {
      if (gi_724 == 1) ls_unused_0 = "both floating profit and loss on open positions.";
      else {
         if (gi_724 == 2) ls_unused_0 = "only profitable values, where current loss on open positions are not included.";
         else
            if (gi_724 == 3) ls_unused_0 = "only loss values are used for calculation, where current profitable open positions are not included.";
      }
   }
   if (gi_728 == 0) ls_unused_8 = "percentage ratio between margin and equity.";
   else
      if (gi_728 == 1) ls_unused_8 = "comparison of the free margin level to the absolute value.";
   Comment("This EA works in only in a SIDEWAYS MARKET!", 
      "\nIf the currency is strongly trending then either remove the EA and wait until the market is Sideways again OR", 
      "\nset the EA to only trade Long or Short in direction of the trend by changing the EA settings.\n\n", "Normal drawdown can be 20-30% when using this EA.", 
      "\nTo close all trades use EA property - UseClose=True.\nIf you wish to manually close positions, remove the EA first. ", 
   "\n\nFor this EA to be PROFITABLE it should run on a dedicated computer.");
   if (Digits == 2 || Digits == 4) g_pips_668 = 1;
   if (Digits == 3 || Digits == 5) g_pips_668 = 10;
   if (Digits == 6) g_pips_668 = 100;
   Print(" Digits:", Digits, " Point:", Point);
   gd_676 = g_pips_668 * Point;
   gd_684 = MarketInfo(Symbol(), MODE_STOPLEVEL) / g_pips_668;
   gd_616 = AccountBalance();
   if (LotSize == 0.01) gd_unused_636 = 100;
   else {
      if (LotSize == 0.1) gd_unused_636 = 10;
      else {
         if (LotSize == 10.0) gd_unused_636 = 1;
         else gd_unused_636 = 1;
      }
   }
   switch (Risk) {
   case 0:
   case 1:
      gd_644 = 0.1;
      break;
   case 2:
      gd_644 = 0.5;
      break;
   case 3:
      gd_644 = 1.0;
      break;
   case 4:
      gd_644 = 1.5;
      break;
   case 5:
      gd_644 = 2;
   }
   if (useMM) LotSize = MathMax(NormalizeDouble(MathFloor(AccountBalance() * PercentageOfAccount / 100.0 / 1000.0) / 100.0 * gd_644, LotDigit), gd_360);
   else gd_628 = LotSize;
   Print("Starting Balance is:", gd_616);
   gd_540 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
   gi_584 = f0_13();
   g_price_500 = 0;
   double ld_32 = 0;
   for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
      bool cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            g_price_500 += OrderOpenPrice() * OrderLots();
            ld_32 += OrderLots();
         }
      }
   }
   if (gi_584 > 0) g_price_500 = NormalizeDouble(g_price_500 / ld_32, Digits);
   Print("AUDUSD Robot for sideways market, Versionn=5.3 and Magic Number=", g_magic_464);
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   double ichimoku_0;
   double ichimoku_8;
   double ichimoku_16;
   double ichimoku_24;
   double order_lots_32;
   double order_lots_40;
   if (gi_744) {
      init();
      return (-1);
   }
   if (updateSLTP) f0_15(gd_212, gd_220, g_price_500);
   if (UseTimeOut) {
      if (TimeCurrent() >= gi_564) {
         f0_8();
         Print("Closed All due to TimeOut");
      }
   }
   if (g_time_560 == Time[0]) return (0);
   g_time_560 = Time[0];
   if (useMM) gd_628 = MathMax(NormalizeDouble(MathFloor(AccountBalance() * PercentageOfAccount / 100.0 / 1000.0) / 100.0 * gd_644, LotDigit), gd_360);
   else gd_628 = LotSize;
   double ld_48 = (Close[gi_316] + (Close[gi_316 + 2]) + (Close[gi_316 + 4]) + (Close[gi_316 + 8])) / 4.0;
   double ld_unused_56 = High[iHighest(NULL, 0, MODE_HIGH, gi_316, gi_320)];
   double ld_unused_64 = Low[iLowest(NULL, 0, MODE_LOW, gi_316, gi_320)];
   g_iatr_652 = iATR(NULL, 0, g_period_348, 0);
   g_iatr_660 = iATR(NULL, 0, g_period_348, 1);
   gd_268 = gd_352 * g_iatr_652 * (1 / (Point * g_pips_668));
   double icustom_72 = 0;
   g_icustom_736 = g_icustom_732;
   if (gi_308) icustom_72 = iCustom(NULL, 0, "snowball indicator", gi_432, gi_436, gi_420, gi_424, gd_456, 4, gi_428);
   if (gi_304) {
      ichimoku_0 = iIchimoku(NULL, 0, gi_376, gi_380, gi_384, MODE_TENKANSEN, gi_388);
      ichimoku_8 = iIchimoku(NULL, 0, gi_376, gi_380, gi_384, MODE_KIJUNSEN, gi_388);
      ichimoku_16 = iIchimoku(NULL, 0, gi_376, gi_380, gi_384, MODE_TENKANSEN, gi_388 + 1);
      ichimoku_24 = iIchimoku(NULL, 0, gi_376, gi_380, gi_384, MODE_KIJUNSEN, gi_388 + 1);
      if (ichimoku_16 > ichimoku_24 && ichimoku_0 < ichimoku_8) icustom_72 = -1;
      else
         if (ichimoku_16 < ichimoku_24 && ichimoku_0 > ichimoku_8) icustom_72 = 1;
   }
   g_icustom_732 = icustom_72;
   if (gi_740 != g_icustom_736) gi_740 = TRUE;
   double ld_80 = f0_12();
   if (UseMaxCapitalStop) {
      if (ld_80 < 0.0 && MathAbs(ld_80) > MaxCapitalToRiskPercent / 100.0 * f0_7()) {
         f0_8();
         Print("Closed All due to Stop Out");
         gi_612 = FALSE;
      }
   }
   gi_584 = f0_13();
   if (gi_584 == 0) gi_548 = FALSE;
   for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
     bool cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
         if (OrderType() == OP_BUY) {
            gi_600 = TRUE;
            gi_604 = FALSE;
            order_lots_32 = OrderLots();
            break;
         }
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
         if (OrderType() == OP_SELL) {
            gi_600 = FALSE;
            gi_604 = TRUE;
            order_lots_40 = OrderLots();
            break;
         }
      }
   }
   if (gi_584 > 0 && gi_584 <= NbTradeMax) {
      RefreshRates();
      gd_524 = f0_1();
      gd_532 = f0_5();
      if (gi_600 && gd_524 - Ask >= gd_268 * Point) gi_596 = TRUE;
      if (gi_604 && Bid - gd_532 >= gd_268 * Point) gi_596 = TRUE;
   }
   if (gi_584 < 1) {
      gi_604 = FALSE;
      gi_600 = FALSE;
      gi_596 = TRUE;
      gd_476 = AccountEquity();
   }
   if (gi_596) {
      gd_524 = f0_1();
      gd_532 = f0_5();
      if (gi_604 && g_icustom_732 == -1) {
         if (UseClose) {
            f0_11(0, 1);
            gd_572 = NormalizeDouble(LotCoeff * order_lots_40, LotDigit);
         } else gd_572 = f0_6(OP_SELL);
         if (gi_256) {
            gi_568 = gi_584;
            if (gd_572 > 0.0) {
               RefreshRates();
               if (useEquityForLotSize) {
                  gi_608 = f0_2(1, MathMax(gd_628 + (AccountBalance() - gd_616) / gd_616 / 10.0 - 0.06, LotSize), Bid, g_slippage_260, Ask, 0, 0, gs_552 + "-" + gi_568, g_magic_464,
                     0, Orange);
               } else gi_608 = f0_2(1, gd_572, Bid, g_slippage_260, Ask, 0, 0, gs_552 + "-" + gi_568, g_magic_464, 0, Orange);
               if (gi_608 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               gd_532 = f0_5();
               gi_596 = FALSE;
               gi_612 = TRUE;
            }
         }
      } else {
         if (gi_600 && g_icustom_732 == 1) {
            if (UseClose) {
               f0_11(1, 0);
               gd_572 = NormalizeDouble(LotCoeff * order_lots_32, LotDigit);
            } else gd_572 = f0_6(OP_BUY);
            if (gi_256) {
               gi_568 = gi_584;
               if (gd_572 > 0.0) {
                  RefreshRates();
                  if (useEquityForLotSize) {
                     gi_608 = f0_2(0, MathMax(gd_628 + (AccountBalance() - gd_616) / gd_616 / 10.0 - 0.06, LotSize), Ask, g_slippage_260, Bid, 0, 0, gs_552 + "-" + gi_568, g_magic_464,
                        0, Blue);
                  } else gi_608 = f0_2(0, gd_572, Ask, g_slippage_260, Bid, 0, 0, gs_552 + "-" + gi_568, g_magic_464, 0, Blue);
                  if (gi_608 < 0) {
                     Print("Error: ", GetLastError());
                     return (0);
                  }
                  gd_524 = f0_1();
                  gi_596 = FALSE;
                  gi_612 = TRUE;
               }
            }
         }
      }
   }
   if (gi_596 && gi_584 < 1) {
      g_bid_508 = Bid;
      g_ask_516 = Ask;
      if (!gi_604) {
         gi_568 = gi_584;
         if ((gi_304 && icustom_72 == -1.0) || (gi_308 && icustom_72 == -1.0)) {
            gd_572 = f0_6(OP_SELL);
            if (gd_572 > 0.0) {
               if (useEquityForLotSize) {
                  gi_608 = f0_2(1, MathMax(gd_628 + (AccountBalance() - gd_616) / gd_616 / 10.0 - 0.06, LotSize), g_bid_508, g_slippage_260, g_bid_508, 0, 0, gs_552 + "-" + gi_568,
                     g_magic_464, 0, Red);
               } else gi_608 = f0_2(1, gd_628, g_bid_508, g_slippage_260, g_bid_508, 0, 0, gs_552 + "-" + gi_568, g_magic_464, 0, Red);
               if (gi_608 < 0) {
                  Print(gd_572, "Error: ", GetLastError());
                  return (0);
               }
               gd_524 = f0_1();
               gi_612 = TRUE;
            }
         }
         if (!gi_600) gi_568 = gi_584;
         if ((gi_304 && icustom_72 == 1.0) || (gi_308 && icustom_72 == 1.0)) {
            gd_572 = f0_6(OP_BUY);
            if (gd_572 > 0.0) {
               if (useEquityForLotSize) {
                  gi_608 = f0_2(0, MathMax(gd_628 + (AccountBalance() - gd_616) / gd_616 / 10.0 - 0.06, LotSize), g_ask_516, g_slippage_260, g_ask_516, 0, 0, gs_552 + "-" + gi_568,
                     g_magic_464, 0, Lime);
               } else gi_608 = f0_2(0, gd_628, g_ask_516, g_slippage_260, g_ask_516, 0, 0, gs_552 + "-" + gi_568, g_magic_464, 0, Lime);
               if (gi_608 < 0) {
                  Print(gd_572, "Error: ", GetLastError());
                  return (0);
               }
               gd_532 = f0_5();
               gi_612 = TRUE;
            }
         }
      }
      if (gi_608 > 0) gi_564 = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours);
      gi_596 = FALSE;
   }
   gi_584 = f0_13();
   g_price_500 = 0;
   double ld_88 = 0;
   for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
      cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            g_price_500 += OrderOpenPrice() * OrderLots();
            ld_88 += OrderLots();
         }
      }
   }
   if (gi_584 > 0) g_price_500 = NormalizeDouble(g_price_500 / ld_88, Digits);
   if (gi_612) {
      for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
         cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
            if (OrderType() == OP_BUY) {
               g_price_468 = g_price_500 + g_pips_196 * Point;
               gd_unused_484 = g_price_468;
               gd_588 = g_price_500 - g_pips_204 * Point;
               gi_548 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
            if (OrderType() == OP_SELL) {
               g_price_468 = g_price_500 - g_pips_196 * Point;
               gd_unused_492 = g_price_468;
               gd_588 = g_price_500 + g_pips_204 * Point;
               gi_548 = TRUE;
            }
         }
      }
   }
   if (gi_612) {
      if (gi_548 == TRUE) {
         for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
            cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) cg = OrderModify(OrderTicket(), g_price_500, OrderStopLoss(), g_price_468, 0, Yellow);
            gi_612 = FALSE;
         }
      }
   }
   return (0);
}

// 78BAA8FAE18F93570467778F2E829047
double f0_9(double ad_0) {
   return (NormalizeDouble(ad_0, Digits));
}

// 9B1AEE847CFB597942D106A4135D4FE6
int f0_11(bool ai_0 = TRUE, bool ai_4 = TRUE) {
   int li_ret_8 = 0;
   for (int pos_12 = OrdersTotal() - 1; pos_12 >= 0; pos_12--) {
      if (OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
            if (OrderType() == OP_BUY && ai_0) {
               RefreshRates();
               if (!IsTradeContextBusy()) {
                  if (!OrderClose(OrderTicket(), OrderLots(), f0_9(Bid), 5, CLR_NONE)) {
                     Print("Error close BUY " + OrderTicket());
                     li_ret_8 = -1;
                  }
               } else {
                  if (g_datetime_752 == iTime(NULL, 0, 0)) return (-2);
                  g_datetime_752 = iTime(NULL, 0, 0);
                  Print("Need close BUY " + OrderTicket() + ". Trade Context Busy");
                  return (-2);
               }
            }
            if (OrderType() == OP_SELL && ai_4) {
               RefreshRates();
               if (!IsTradeContextBusy()) {
                  if (!((!OrderClose(OrderTicket(), OrderLots(), f0_9(Ask), 5, CLR_NONE)))) continue;
                  Print("Error close SELL " + OrderTicket());
                  li_ret_8 = -1;
                  continue;
               }
               if (g_datetime_756 == iTime(NULL, 0, 0)) return (-2);
               g_datetime_756 = iTime(NULL, 0, 0);
               Print("Need close SELL " + OrderTicket() + ". Trade Context Busy");
               return (-2);
            }
         }
      }
   }
   return (li_ret_8);
}

// 58B0897F29A3AD862616D6CBF39536ED
double f0_6(int a_cmd_0) {
   double ld_ret_4;
   int datetime_12;
   int count_16;
   switch (gi_252) {
   case 0:
      ld_ret_4 = LotSize;
      break;
   case 1:
      if (gi_568 >= gd_236) {
         Print("Past Lot Exponent Threshold, Scaling to exit the trade");
         ld_ret_4 = NormalizeDouble(LotSize * MathPow(LotCoeff, gi_568), LotDigit);
      } else ld_ret_4 = LotSize;
      break;
   case 2:
      datetime_12 = 0;
      count_16 = 0;
      ld_ret_4 = LotSize;
      for (int pos_24 = OrdersHistoryTotal() - 1; pos_24 >= 0; pos_24--) {
         if (!OrderSelect(pos_24, SELECT_BY_POS, MODE_HISTORY)) return (-3);
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
            if (datetime_12 < OrderCloseTime()) {
               datetime_12 = OrderCloseTime();
               if (OrderProfit() < 0.0) {
                  count_16++;
                  if (count_16 < gd_236) continue;
                  ld_ret_4 = NormalizeDouble(OrderLots() * LotCoeff, LotDigit);
                  continue;
               }
               ld_ret_4 = LotSize;
               count_16 = 0;
            }
         }
      }
   }
   if (AccountFreeMarginCheck(Symbol(), a_cmd_0, ld_ret_4) <= 0.0) return (-1);
   if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
   return (ld_ret_4);
}

// AA5EA51BFAC7B64E723BF276E0075513
int f0_13() {
   int count_0 = 0;
   for (int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--) {
      bool cg = OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

// 6ABA3523C7A75AAEA41CC0DEC7953CC5
void f0_8() {
   for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
      bool cg = OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464) {
            if (OrderType() == OP_BUY)  cg = OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_260, Blue);
            if (OrderType() == OP_SELL) cg = OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_260, Red);
         }
         Sleep(1000);
      }
   }
}

// 28EFB830D150E70A8BB0F12BAC76EF35
int f0_2(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int li_72 = 100;
   switch (ai_0) {
   case 2:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, f0_4(ad_24, ai_32), f0_3(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52,
            a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(1000);
      }
      break;
   case 4:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, f0_4(ad_24, ai_32), f0_3(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52,
            a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 0:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         RefreshRates();
         ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, f0_4(Bid, ai_32), f0_3(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 3:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, f0_10(ad_24, ai_32), f0_0(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52,
            a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 5:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, f0_10(ad_24, ai_32), f0_0(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52,
            a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 1:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, f0_10(Ask, ai_32), f0_0(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
   }
   return (ticket_60);
}

// 50257C26C4E5E915F022247BABD914FE
double f0_4(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 - ai_8 * Point);
}

// 945D754CB0DC06D04243FCBA25FC0802
double f0_10(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 + ai_8 * Point);
}

// 2FC9212C93C86A99B2C376C96453D3A4
double f0_3(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 + ai_8 * Point);
}

// 09CBB5F5CE12C31A043D5C81BF20AA4A
double f0_0(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 - ai_8 * Point);
}

// A9B24A824F70CC1232D1C2BA27039E8D
double f0_12() {
   double ld_ret_0 = 0;
   for (g_pos_580 = OrdersTotal() - 1; g_pos_580 >= 0; g_pos_580--) {
      bool cg = OrderSelect(g_pos_580, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
   }
   return (ld_ret_0);
}

// D362D41CFF235C066CFB390D52F4EB13
void f0_15(int ai_0, int ai_4, double ad_8) {
   int li_16;
   double order_stoploss_20;
   double order_takeprofit_28;
   double price_36;
   double ld_44;
   double ld_52;
   double ld_60;
   gi_288 = TRUE;
   if (gi_292) ld_44 = gd_268 / gd_412;
   else ld_44 = ai_4;
   if (gi_288) ld_52 = gd_268 * gd_296;
   else ld_52 = ai_0;
   ld_44 = MathMax(ld_44, gd_684);
   ld_52 = MathMax(ld_52, gd_684);
   RefreshRates();
   if (ai_4 != 0) {
      for (int pos_68 = OrdersTotal() - 1; pos_68 >= 0; pos_68--) {
         if (OrderSelect(pos_68, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
            if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic_464) {
               if (gi_324) {
                  f0_14(OrderTicket(), ad_8);
                  continue;
               }
               if (OrderType() == OP_BUY) {
                  li_16 = NormalizeDouble((Bid - ad_8) / Point, 0);
                  if (li_16 < ld_52) continue;
                  order_stoploss_20 = OrderStopLoss();
                  order_takeprofit_28 = OrderTakeProfit();
                  price_36 = Bid - ld_44 * gd_676;
                  ld_60 = Bid + ld_52 * gd_676;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_36 > order_stoploss_20)) {
                     if (MathAbs(price_36 - order_stoploss_20) > gd_684 * gd_676 || MathAbs(ld_60 - order_takeprofit_28) > gd_684 * gd_676)
                        if (!OrderModify(OrderTicket(), OrderOpenPrice(), price_36, OrderTakeProfit(), 0, Aqua)) Print("Failed OP_BUY OrderModify, Bid: " + Bid + ", OrderOpenPrice: " + OrderOpenPrice() + ", OrderStopLoss: " + OrderStopLoss() + " , newSL: " + price_36);
                  }
               }
               if (OrderType() == OP_SELL) {
                  li_16 = NormalizeDouble((ad_8 - Ask) / Point, 0);
                  if (li_16 < ld_52) continue;
                  order_stoploss_20 = OrderStopLoss();
                  order_takeprofit_28 = OrderTakeProfit();
                  price_36 = Ask + ld_44 * gd_676;
                  ld_60 = Ask - ld_52 * gd_676;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_36 < order_stoploss_20)) {
                     if (MathAbs(price_36 - order_stoploss_20) > gd_684 * gd_676 || MathAbs(ld_60 - order_takeprofit_28) > gd_684 * gd_676)
                        if (!OrderModify(OrderTicket(), OrderOpenPrice(), price_36, OrderTakeProfit(), 0, Red)) Print("Failed OP_SELL OrderModify, Ask: " + Ask + ", OrderOpenPrice: " + OrderOpenPrice() + ", OrderStopLoss: " + OrderStopLoss() + " , newSL: " + price_36);
                  }
               }
            }
            Sleep(1000);
         }
      }
   }
}

// 689C35E4872BA754D7230B8ADAA28E48
double f0_7() {
   if (f0_13() == 0) gd_760 = AccountEquity();
   if (gd_760 < gd_768) gd_760 = gd_768;
   else gd_760 = AccountEquity();
   gd_768 = AccountEquity();
   return (gd_760);
}

// 2569208C5E61CB15E209FFE323DB48B7
double f0_1() {
   double order_open_price_0;
   int ticket_8;
   double ld_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      bool cg = OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464 && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 5710F6E623305B2C1458238C9757193B
double f0_5() {
   double order_open_price_0;
   int ticket_8;
   double ld_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      bool cg = OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_464) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_464 && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// D1DDCE31F1A86B3140880F6B1877CBF8
void f0_14(int a_pos_0, double a_price_4) {
   bool bool_12;
   double ld_16 = iSAR(NULL, 0, gd_328, gd_336, 0);
   if (OrderSelect(a_pos_0, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderType() == OP_BUY) {
         ld_16 -= gi_344 * gd_676;
         if (gi_452) ld_16 -= MarketInfo(Symbol(), MODE_SPREAD) * Point;
         if (!((NormalizeDouble(OrderStopLoss(), Digits) < NormalizeDouble(ld_16, Digits) && NormalizeDouble(Bid - gd_684 * gd_676, Digits) > NormalizeDouble(ld_16, Digits)))) return;
         bool_12 = OrderModify(OrderTicket(), a_price_4, NormalizeDouble(ld_16, Digits), OrderTakeProfit(), 0, Blue);
         if (!((!bool_12))) return;
         Print("Error modifying order on candletrail: ", GetLastError());
         return;
      }
      if (OrderType() == OP_SELL) {
         ld_16 += gi_344 * gd_676;
         if (gi_452) ld_16 += MarketInfo(Symbol(), MODE_SPREAD) * Point;
         if (NormalizeDouble(OrderStopLoss(), Digits) > NormalizeDouble(ld_16, Digits) || (OrderStopLoss() == 0.0 && NormalizeDouble(Ask + gd_684 * gd_676, Digits) < NormalizeDouble(ld_16,
            Digits))) {
            bool_12 = OrderModify(OrderTicket(), a_price_4, NormalizeDouble(ld_16, Digits), OrderTakeProfit(), 0, Red);
            if (!bool_12) Print("Error modifying order on candletrail: ", GetLastError());
         }
      }
   }
}

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