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

智能交易系统Panda_1_Scalper+sl EA



Panda_1_Scalper+sl EA自身带有指标,可以设定根据风险系数和盈利自动增加手数,或者用固定手数交易。在编程技巧及指标调用方面可以参考。

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

智能交易EA Panda_1_Scalper+sl EA的MQL4源码如下:(指标模板请在最下方附近下载)

//+------------------------------------------------------------------+
//|                                        Panda_1_Scalper+sl,tp.mq4 |
//|                                     Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

extern int     TakeProfit           = 75;    
extern int     StopLoss             = 40;    
extern double MinLots = 0.1;
extern double MaxLot = 10.0;
extern double MarginRisk = 20.0;

extern int     TrailingStop         = 27;   
extern int     TrailingStep         = 2;     
extern int     BU                   = 25;    
extern int     MinProfitBU          = 5;     
int Tracking,TimeBar;
int    gi_108     = 0; 
int gi_unused_100 = 100;
int gi_104 = 4;
extern int GMTOffSet = 1;
extern int LotDigits = 1;
int g_ticket_132;
double g_lots_144;
double g_ord_open_price_152;
double gd_160;
int g_ticket_168;
double g_ord_lots_172;
int g_cmd_180;

//+------------------------------------------------------------------+
int init()
{

 return(0);
  }
//+------------------------------------------------------------------+

double LotsOptimized() {
   double ld_0 = NormalizeDouble(AccountFreeMargin() * MarginRisk / 100000.0, 2);
   if (ld_0 < MinLots) ld_0 = MinLots;
   if (ld_0 > MaxLot) ld_0 = MaxLot;
   if (ld_0 < MarketInfo(Symbol(), MODE_MINLOT)) ld_0 = MarketInfo(Symbol(), MODE_MINLOT);
   if (ld_0 > 33.0) ld_0 = 33;
   return (NormalizeDouble(ld_0, LotDigits));
}

double PointValue() {
   if (MarketInfo(Symbol(), MODE_DIGITS) == 5.0 || MarketInfo(Symbol(), MODE_DIGITS) == 3.0) 
return (10.0 * Point);
   return (Point);
}

double SecondTrade() {
   bool li_ret_0 = TRUE;
   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() == 912134301) li_ret_0 = FALSE;
   }
   return (li_ret_0);
}

double ThirdTrade() {
   bool li_ret_0 = TRUE;
   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() == 912134302) li_ret_0 = FALSE;
   }
   return (li_ret_0);
}

void CloseAllOpenTrades() {
   for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
      if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && (OrderMagicNumber() == 2116193 || OrderMagicNumber() == 912134301 || 
OrderMagicNumber() == 912134302)) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               CloseTicket(OrderTicket());
               Sleep(500);
            }
         }
      }
   }
}

void CloseTicket(int a_ticket_0) {
   int l_cmd_4;
   double ld_8;
   double l_price_16;
   int l_count_36 = 0;
   int li_40 = 60;
   bool l_ord_close_44 = FALSE;
   if (isTradingAllowed(300) >= 0) {
      l_cmd_4 = OrderType();
      if (OrderType() == OP_BUY) ld_8 = NormalizeDouble(Bid, Digits);
      else ld_8 = NormalizeDouble(Ask, Digits);
      while (!l_ord_close_44 && l_count_36 < li_40) {
         if (OrderType() == OP_BUY) l_price_16 = NormalizeDouble(Bid, Digits);
         else l_price_16 = NormalizeDouble(Ask, Digits);
         if (OrderType() == OP_BUY) l_ord_close_44 = OrderClose(a_ticket_0, OrderLots(), l_price_16, 0, Green);
         else l_ord_close_44 = OrderClose(a_ticket_0, OrderLots(), l_price_16, 0, Red);
         if (l_ord_close_44) break;
         if (IsStopped()) break;
         if (GetLastError() == 4108/* INVALID_TICKET */) break;
         Sleep(500);
         l_count_36++;
      }
   }
}

int isTradingAllowed(int ai_0, int ai_unused_4 = 10) {
   string ls_unused_8;
   int li_16;
   if (!IsTradeAllowed()) {
      if (ai_0 == 200) ls_unused_8 = "Opening";
      else ls_unused_8 = "Closing";
      li_16 = GetTickCount();
   } else return (1);
   return (0);
}

void CheckForOpen() {
   if (iCustom(NULL, PERIOD_M1, "Laguerre", 0.7, 950, 0, 1) >= 0.9 && 
iCustom(NULL, PERIOD_M1, "Turbo_JRSX2", 5, 0, 1) > 90.0 && Open[1] > Close[1]) g_ticket_132 = OrderSend(Symbol(), 
OP_SELL, LotsOptimized(), NormalizeDouble(Bid, Digits), 2, 0, 0, "", 2116193, 0, Red);
   if (iCustom(NULL, PERIOD_M1, "Laguerre", 0.7, 950, 0, 1) <= 0.1 && 
iCustom(NULL, PERIOD_M1, "Turbo_JRSX2", 5, 0, 1) < 10.0 && Open[1] < Close[1]) g_ticket_132 = OrderSend(Symbol(),
 OP_BUY, LotsOptimized(), NormalizeDouble(Ask, Digits), 2, 0, 0, "", 2116193, 0, Green);
}

void start() {
   Tracking=MarketInfo(Symbol(),MODE_STOPLEVEL); 
   if(gi_108>OrdersTotal())
   gi_108 = OrdersTotal();
   double OSL,OTP,OOP,StLo,SL,TP;
   double ProfitS,ProfitB,LB,LS,NLb,NLs,price_b,price_s,OL;
   int b,s,OT,Magic;
 
   for (int i=OrdersTotal()-1; i>=0; i--)
    {                                          
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    {
   Magic = OrderMagicNumber();
   if (OrderSymbol() == Symbol())
    {
   OOP = NormalizeDouble(OrderOpenPrice(),Digits);
   OT = OrderType();
   OL = OrderLots();
   if (OT==OP_BUY)
    {
   price_b = price_b+OOP*OL;
   b++; LB+= OL;
   ProfitB+=OrderProfit()+OrderSwap()+OrderCommission();
    }
   if (OT==OP_SELL)
    {
   price_s = price_s+OOP*OL;
   s++;LS+= OL;
   ProfitS+=OrderProfit()+OrderSwap()+OrderCommission();
    }}}}
   if (b>0) 
    {
   NLb = NormalizeDouble(price_b/LB,Digits);
    }
   if (s>0) 
    {
   NLs = NormalizeDouble(price_s/LS,Digits);
    }
   int OTicket;
   for (i=0; i<OrdersTotal(); i++)
    {    
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    {
   if (OrderSymbol()==Symbol())
    { 
   OT = OrderType(); 
   OSL = NormalizeDouble(OrderStopLoss(),Digits);
   OTP = NormalizeDouble(OrderTakeProfit(),Digits);
   OOP = NormalizeDouble(OrderOpenPrice(),Digits);
   SL=OSL;TP=OTP;
   if (OT==OP_BUY)             
    {  
   b++;
   if (OSL==0 && StopLoss>=Tracking && StopLoss!=0)
    {
   SL = NormalizeDouble(Bid - StopLoss * Point,Digits);
    } 
   else SL=OSL;
   if (OTP==0 && TakeProfit>=Tracking && TakeProfit!=0)
    {
   TP = NormalizeDouble(Ask + TakeProfit * Point,Digits);
    } 
   else TP=OTP;
   if (BU>=Tracking && OSL<NLb && BU!=0)
    {
   if (OOP<=NLb && NLb!=0 && NLb <= NormalizeDouble(Bid-BU * Point,Digits)) 
   SL = NormalizeDouble(NLb+MinProfitBU * Point,Digits);
    }
   if (TrailingStop>=Tracking && TrailingStop!=0)
    {
   StLo = NormalizeDouble(Bid - TrailingStop * Point,Digits); 
   if (StLo>=NLb && NLb!=0) if (StLo > OSL) SL = StLo;
    }
   if (SL != OSL || TP != OTP)
    {  
   OTicket=OrderTicket();
   if (!OrderModify(OTicket,OOP,SL,TP,0,White)) Print("Error OrderModify ",GetLastError());
   
    }}                                         
   if (OT==OP_SELL)        
    {
   s++;
   if (OSL==0 && StopLoss>=Tracking && StopLoss!=0)
    {
   SL = NormalizeDouble(Ask + StopLoss * Point,Digits);
    }
   else SL=OSL;
   if (OTP==0 && TakeProfit>=Tracking && TakeProfit!=0)
    {
   TP = NormalizeDouble(Bid - TakeProfit * Point,Digits);
    }
   else TP=OTP;
   if (BU>=Tracking && (OSL>NLs || OSL==0) && BU!=0)
    {
   if (OOP>=NLs && NLs!=0 && NLs >= NormalizeDouble(Ask+BU * Point,Digits)) 
   SL = NormalizeDouble(NLs-MinProfitBU*Point,Digits);
    }
   if (TrailingStop>=Tracking && TrailingStop!=0)
    {
   StLo = NormalizeDouble(Ask + TrailingStop * Point,Digits); 
   if (StLo<=NLs && NLs!=0) if (StLo < OSL || OSL==0) SL = StLo;
    }
   if ((SL != OSL || OSL==0) || TP != OTP)
    {  
   OTicket=OrderTicket();
   if (!OrderModify(OTicket,OOP,SL,TP,0,White)) Print("Error OrderModify ",GetLastError());
    }
      } 
        }
      }
    }  
   if (OrdersTotal() > 0) {
      for (int 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() == 2116193) {
            g_ord_open_price_152 = NormalizeDouble(OrderOpenPrice(), Digits);
            gd_160 = NormalizeDouble(OrderStopLoss(), Digits);
            g_ticket_168 = OrderTicket();
            g_ord_lots_172 = OrderLots();
            g_cmd_180 = OrderType();
            g_lots_144 = NormalizeDouble(3.0 * g_ord_lots_172, LotDigits);
    
 
            if (g_cmd_180 == OP_BUY) {
               if (g_ord_open_price_152 - Bid > 10.0 * PointValue() && SecondTrade()) cg = OrderSend(Symbol(),
 OP_BUY, LotsOptimized(), NormalizeDouble(Ask, Digits), 2, 0, 0, "", 912134301, 0, Green);
               if (g_ord_open_price_152 - Bid > 15.0 * PointValue() && ThirdTrade()) cg = OrderSend(Symbol(), 
OP_BUY, g_lots_144, NormalizeDouble(Ask, Digits), 2, 0, 0, "", 912134302, 0, Green);
            }
            if (g_cmd_180 == OP_SELL) {
               if (Ask - g_ord_open_price_152 > 10.0 * PointValue() && SecondTrade()) cg = OrderSend(Symbol(), 
OP_SELL, LotsOptimized(), NormalizeDouble(Bid, Digits), 2, 0, 0, "", 912134301, 0, Red);
               if (Ask - g_ord_open_price_152 > 15.0 * PointValue() && ThirdTrade()) cg = OrderSend(Symbol(), 
OP_SELL, g_lots_144, NormalizeDouble(Bid, Digits), 2, 0, 0, "", 912134302, 0, Red);
            }
         }
      }
   }
   bool li_4 = TRUE;
   for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) {
      cg = OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == 2116193) {
         g_ord_open_price_152 = OrderOpenPrice();
         g_ord_lots_172 = OrderLots();
         g_ticket_168 = OrderTicket();
         g_cmd_180 = OrderType();
         if (SecondTrade() == 1.0 && ThirdTrade() == 1.0) {
            if (g_cmd_180 == OP_SELL)
               if (g_ord_open_price_152 - Ask >= gi_104 * PointValue()) cg = OrderClose(g_ticket_168, 
g_ord_lots_172, NormalizeDouble(Ask, Digits), 1, Red);
            if (g_cmd_180 == OP_BUY)
               if (Bid - g_ord_open_price_152 >= gi_104 * PointValue()) cg = OrderClose(g_ticket_168, 
g_ord_lots_172, NormalizeDouble(Bid, Digits), 1, Green);
         }
         if (SecondTrade() == 0.0 && ThirdTrade() == 1.0) {
            if (g_cmd_180 == OP_SELL)
               if (g_ord_open_price_152 >= Ask) CloseAllOpenTrades();
            if (g_cmd_180 == OP_BUY)
               if (g_ord_open_price_152 <= Bid) CloseAllOpenTrades();
         }
         if (SecondTrade() == 0.0 && ThirdTrade() == 0.0) {
            for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) {
               cg = OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
               if (OrderSymbol() == Symbol() && OrderMagicNumber() == 912134301) {
                  if (OrderOpenPrice() > Ask && g_cmd_180 == OP_SELL) CloseAllOpenTrades();
                  if (OrderOpenPrice() < Bid - 2.0 * PointValue() && g_cmd_180 == OP_BUY) CloseAllOpenTrades();
               }
            }
         }
      }
   }
   for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) {
      cg = OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && (OrderMagicNumber() == 2116193 || OrderMagicNumber() == 912134301 
|| OrderMagicNumber() == 912134302)) li_4 = FALSE;
   }
   if (li_4 == TRUE) {
      if (Day() != 13 && DayOfWeek() != 5 && DayOfWeek() != 1 && (Hour() < GMTOffSet || 
(Hour() >= GMTOffSet + 19 && Hour() < GMTOffSet + 19 + 5))) CheckForOpen();
      if (Day() != 13 && DayOfWeek() == 5 && Hour() < GMTOffSet) CheckForOpen();
      if (Day() != 13 && DayOfWeek() == 1 && (Hour() >= GMTOffSet + 19 && Hour() < GMTOffSet + 19 + 5)) 
CheckForOpen();
      if (Day() == 13 && DayOfWeek() != 5 && DayOfWeek() != 1 && (Hour() < GMTOffSet || 
(Hour() >= GMTOffSet + 20 && Hour() < GMTOffSet + 19 + 5))) CheckForOpen();
      if (Day() == 13 && DayOfWeek() == 5 && Hour() < GMTOffSet) CheckForOpen();
      if (Day() == 13 && DayOfWeek() == 1 && (Hour() >= GMTOffSet + 20 && Hour() < GMTOffSet + 20 + 5)) 
CheckForOpen();

}    
  }

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