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

根据AC指标设计的超短剥头皮EA AI_REVERS



AI_REVERS EA根据AC指标设计,属于超短剥头皮类型,单量大,如何有效的控制交易时间及盈亏系数乃是关键。

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

AI_REVERS EA源码如下:

//+------------------------------------------------------------------+
//|                                 ArtificialIntelligenceRevers.mq4 |
//|                                Copyright @2006, Yury V. Reshetov |
//|                                Modifed by   Leonid553            |
//|                                  http://www.tradersforum.net.ru/ | 
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright @2006, Yury V. Reshetov ICQ:282715499"
 #property link      "http://reshetov.xnet.uz/"
//---- input parameters
extern int    x1 = 88;
extern int    x2 = 172;
extern int    x3 = 39;
extern int    x4 = 172;
// StopLoss level
extern double sl = 50;
extern double lots = 0.1;
extern int    MagicNumber = 808;
static int prevtime = 0;
static int spread = 3;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
Comment("www.125808047.com");
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
     Comment(perceptron());   
// Waite for the formation of a new candlestick
// If a new candlestick appears, check for the possibility of a trade 
if(Time[0] == prevtime) 
       return(0);
   prevtime = Time[0];
//----
   if(IsTradeAllowed()) 
     {
       spread = MarketInfo(Symbol(), MODE_SPREAD);
     } 
   else 
     {
       prevtime = Time[1];
       return(0);
     }
   int ticket = -1;
   // check for opened position
   int total = OrdersTotal();   
   for(int i = 0; i < total; i++) 
     {
       bool cg = OrderSelect(i, SELECT_BY_POS, MODE_TRADES); 
       // check for symbol & magic number
  if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) 
         {
           int prevticket = OrderTicket();
           // long position is opened
           if(OrderType() == OP_BUY) 
              // if a long position is opened and ...
             {
               // check profit 
   // the current profit is larger than the value of =(stoploss + spread) and ...
         if(Bid > (OrderStopLoss() + (sl * 2  + spread) * Point)) 
                 {               
                   if(perceptron() > 0) 
                     { 
      // perceptron is more than zero, then turn to Sell
                       // reverse
         ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, 
                         Ask + sl * Point, 0, "AI", MagicNumber, 
                                          0, Red); 
                       Sleep(30000);
                       if(ticket < 0) 
                         {
                           prevtime = Time[1];
                         } 
                       else 
                         {
                           cg = OrderCloseBy(ticket, prevticket, Blue);   
                         }
                     } 
                   else 
//if perceptron is less than zero, trail the stoploss 
                     { 
                       // trailing stop
                       if(!OrderModify(OrderTicket(), OrderOpenPrice(), 
                          Bid - sl * Point, 0, 0, Blue)) 
                         {
                           Sleep(30000);
                           prevtime = Time[1];
                         }
                     }
                 }  
               // short position is opened
             } 
           else 
             {
               // if a short position is opened and ...
               // check profit 
           if(Ask < (OrderStopLoss() - (sl * 2 + spread) * Point)) 
                 {
        // the current profit is larger than the value of =(stoploss + spread) and ...
                   if(perceptron() < 0) 
                     { 
             // perceptron is less than zero, then turn to Buy
                       // reverse
             ticket = OrderSend(Symbol(), OP_BUY, lots * 2, Ask, 3, 
                           Bid - sl * Point, 0, "AI", MagicNumber,
                                          0, Blue); 
                       Sleep(30000);
                       if(ticket < 0) 
                         {
                           prevtime = Time[1];
                         } 
                       else 
                         {
                           cg = OrderCloseBy(ticket, prevticket, Blue);   
                         }
                     } 
                   else 
//if perceptron is more than zero, trail the stoploss 
                     { 
                       // trailing stop
                       if(!OrderModify(OrderTicket(), OrderOpenPrice(), 
                          Ask + sl * Point, 0, 0, Blue)) 
                         {
                           Sleep(30000);
                           prevtime = Time[1];
                         }  
                     }
                 }  
             }
           // exit
           return(0);
         }
     }
//********************************************************************
   // check for long or short position possibility
   // initial entrance to the market:
 
   if(perceptron() < 0) 
     { 
        // if the perceptron is less than zero, open a long position :
       //long
 ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, 0, 
                      "AI", MagicNumber, 0, Blue); 
       if(ticket < 0) 
         {
           Sleep(30000);
           prevtime = Time[1];
         }
     } 
   else 
      // if the perceptron is more than zero, open a short position:
     { 
       // short
ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, 0, 
                      "AI", MagicNumber, 0, Red); 
       if(ticket < 0) 
         {
           Sleep(30000);
           prevtime = Time[1];
         }
     }
//--- exit
   return(0);
  }
//+------------------------------------------------------------------+
//|  The PERCEPRRON - a perceiving and recognizing function          |
//+------------------------------------------------------------------+
double perceptron() 
  {
   double w1 = x1 - 100.0;
   double w2 = x2 - 100.0;
   double w3 = x3 - 100.0;
   double w4 = x4 - 100.0;
   double a1 = iAC(Symbol(), 0, 0);
   double a2 = iAC(Symbol(), 0, 7);
   double a3 = iAC(Symbol(), 0, 14);
   double a4 = iAC(Symbol(), 0, 21);
   return (w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
  }
//+------------------------------------------------------------------+}
如您喜欢此文章请点下面分享按钮↴峰汇在线 » 根据AC指标设计的超短剥头皮EA AI_REVERS
上一篇:
下一篇:
分享到:更多 ()