我想请教论坛里的EA大神们,这个EA代码能帮我翻译下工作原理吗,谢谢了

要添加评论,请登录注册
xd345206971
7
xd345206971  
 #property copyright ""
#property link      ""

extern int MinPrfofit = 1;
extern int MaxLoss = 10;
extern int Delta = 3;
extern int BB_Period = 1;
extern int BB_Deviation = 2;
extern bool FixLotMM = FALSE;
extern double FixLotSize = 0.1;
extern double RiskPercent = 10.0;
extern int Slippage = 2;
extern string Comm = "Mathematical_Analysis";
bool gi_unused_128 = TRUE;
int g_magic_132;
int gi_unused_136;
double g_stoplevel_140;
double g_spread_148;
double g_maxlot_156;
double g_minlot_164;
double g_lotstep_172;
double g_lots_180;
double gd_188;
 

 
double setpoint() {
   double l_point_0;
   if (Digits == 3) l_point_0 = 0.01;
   else {
      if (Digits == 5) l_point_0 = 0.0001;
      else l_point_0 = Point;
   }
   return (l_point_0);
}

int init() {
   gi_unused_136 = 3;
   g_magic_132 = StringGetChar(Symbol(), 0) + 77704 + StringGetChar(Symbol(), 1) * 2 + 3 * StringGetChar(Symbol(), 3) + StringGetChar(Symbol(), 4) << 2 + 10000 * Period();
   g_stoplevel_140 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   g_spread_148 = MarketInfo(Symbol(), MODE_SPREAD);
   g_maxlot_156 = MarketInfo(Symbol(), MODE_MAXLOT);
   g_minlot_164 = MarketInfo(Symbol(), MODE_MINLOT);
   g_lotstep_172 = MarketInfo(Symbol(), MODE_LOTSTEP);
   HideTestIndicators(TRUE);
   return (0);
}

int start() {
   string ls_unused_0;
   double l_price_8;
   double l_price_16;
   double ld_24;
   bool li_32;
   bool li_36;
 
   Comment("");
   if (FixLotMM) g_lots_180 = FixLotSize;
   else g_lots_180 = AccountFreeMargin() / 1000.0 * (RiskPercent / 100.0);
   if (g_lots_180 < g_minlot_164) g_lots_180 = g_minlot_164;
   else {
      if (g_lots_180 > g_maxlot_156) g_lots_180 = g_maxlot_156;
      else {
         for (gd_188 = g_minlot_164; gd_188 <= g_lots_180; gd_188 += g_lotstep_172) {
         }
         g_lots_180 = gd_188 - g_lotstep_172;
      }
   }
   if (g_lots_180 > 2300.0) g_lots_180 = NormalizeDouble(g_lots_180, 0);
   for (int l_pos_40 = OrdersTotal() - 1; l_pos_40 >= 0; l_pos_40--) {
      OrderSelect(l_pos_40, SELECT_BY_POS);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_132) continue;
      if (OrderType() == OP_BUY) {
         ld_24 = Bid - OrderOpenPrice();
         if ((MinPrfofit > 0 && ld_24 >= MinPrfofit * setpoint()) || (MaxLoss > 0 && ld_24 <= (-1 * MaxLoss) * setpoint())) {
            OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Purple);
            return (0);
         }
      }
      if (OrderType() == OP_SELL) {
         ld_24 = OrderOpenPrice() - Ask;
         if ((MinPrfofit > 0 && ld_24 >= MinPrfofit * setpoint()) || (MaxLoss > 0 && ld_24 <= (-1 * MaxLoss) * setpoint())) {
            OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
            return (0);
         }
      }
      return (0);
   }
   double l_ibands_44 = iBands(Symbol(), 0, BB_Period, BB_Deviation, 0, PRICE_OPEN, MODE_UPPER, 0);
   double l_ibands_52 = iBands(Symbol(), 0, BB_Period, BB_Deviation, 0, PRICE_OPEN, MODE_LOWER, 0);
   if (Close[0] > l_ibands_44 + Delta * setpoint()) li_36 = TRUE;
   else li_36 = FALSE;
   if (Close[0] < l_ibands_52 - Delta * setpoint()) li_32 = TRUE;
   else li_32 = FALSE;
   if (li_32) {
      if (MaxLoss == 0) l_price_8 = 0;
      else l_price_8 = Ask - (MaxLoss + g_stoplevel_140) * setpoint();
      if (MinPrfofit == 0) l_price_16 = 0;
      else l_price_16 = Ask + (MinPrfofit + g_stoplevel_140 + g_spread_148) * setpoint();
      OrderSend(Symbol(), OP_BUY, g_lots_180, Ask, Slippage, l_price_8, l_price_16, Comm, g_magic_132, 16711680);
   }
   if (li_36) {
      if (MaxLoss == 0) l_price_8 = 0;
      else l_price_8 = Bid + (MaxLoss + g_stoplevel_140) * setpoint();
      if (MinPrfofit == 0) l_price_16 = 0;
      else l_price_16 = Bid - (MinPrfofit + g_stoplevel_140 + g_spread_148) * setpoint();
      OrderSend(Symbol(), OP_SELL, g_lots_180, Bid, Slippage, l_price_8, l_price_16, Comm, g_magic_132, 255);
   }
   return (0);
}

要添加评论,请登录注册