mql4 mt4 ea 20% 盈利

未结帖
0 1026
ajian admin_jim 2018-04-16
悬赏:5飞吻
//+------------------------------------------------------------------+
//|                                                     disaster.mq4 |
//|                                                         Max Fade |
//|                                                          http:// |
//+------------------------------------------------------------------+
#property copyright "Jimmy"
#property link      "http://blog.jimmyacrbin.com"
extern double StopLoss = 200;
extern double TakeProfit = 200;
extern int ModelStyle = 1;
extern int PeriodOption = 30;
extern int BarJump = 2;
extern int MAPER = 590;
int Magic = 54321;

datetime TradeTimeOut;

datetime nowT;

int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
int start()
  {
  
    /*
    int handle = FileOpen("file.csv", FILE_CSV|FILE_WRITE, ";");
    if(handle>0){
     // 写入表格栏标题
     FileWrite(handle, "Time;Open;High;Low;Close;Volume");
     // 记录数据
     for(int w=0; w<Bars; w++){
       FileWrite(handle, Time[w], Open[w], High[w], Low[w], Close[w], Volume[w]);
       FileClose(handle);
     
     }

    }
    
  
   Print("Bid",":",Bid,"---","Ask",Ask,"---");
   Print("一分钟",iClose("EURUSD",1,0),":",iClose("EURUSD",1,1));
   return(0);
  
   */
      int preOrderType=-1,preTicket=0;
      
      double prePriceOpen=0,prePriceClose=0,preTP=0,preSL=0;
      bool STOPLEVELCHECK;
      int e,i,m,n,j,k,l,ticket,err,nBars=0,numOrdersCount=0,numSLCount=0,pass=1;
      
      double Price = 0.0;
      double nowBhPrice = 0.0;
      double nowBmPrice = 0.0;
      double nowBlPrice = 0.0;
      double preBhPriceOne = 0.0;
      double preBmPriceOne = 0.0;
      double preBlPriceOne = 0.0;
      double preBhPriceTwo = 0.0;
      double preBmPriceTwo = 0.0;
      double preBlPriceTwo = 0.0;
      double nowClosePrice = 0.0;
      double preClosePrice = 0.0;
      
      double nowClosePriceH1 = 0.0;
      double preClosePriceH1 = 0.0;
      double tpreClosePriceH1 = 0.0;
      
      int total=OrdersTotal();
      
      nowClosePrice = iClose("EURUSD",PERIOD_H4,0);
      preClosePrice = iClose("EURUSD",PERIOD_H4,1);
      
      nowClosePriceH1 = iClose("EURUSD",PERIOD_H1,0);
      preClosePriceH1 = iClose("EURUSD",PERIOD_H1,1);
      tpreClosePriceH1 = iClose("EURUSD",PERIOD_H1,2);
      //当前布林带最高价
      nowBhPrice = iBands("EURUSD",PeriodOption,20,2,0,4,1,0);
      //当前布林带最低价
      nowBlPrice = iBands("EURUSD",PeriodOption,20,2,0,4,2,0);
      nowBmPrice = (nowBhPrice+nowBlPrice)/2;
      preBhPriceOne = iBands("EURUSD",PeriodOption,20,2,0,4,1,BarJump);
      preBlPriceOne = iBands("EURUSD",PeriodOption,20,2,0,4,2,BarJump);
      preBmPriceOne = (preBhPriceOne+preBlPriceOne)/2;
      preBhPriceTwo = iBands("EURUSD",PeriodOption,20,2,0,4,1,BarJump*2);
      preBlPriceTwo = iBands("EURUSD",PeriodOption,20,2,0,4,2,BarJump*2);
      preBmPriceTwo = (preBhPriceTwo+preBlPriceTwo)/2;
      

               
       for (m=total;m>=0;m--){
         if (OrderSelect(m,SELECT_BY_POS,MODE_TRADES)==false) continue;  

              if(OrderProfit()<-20){
              
                Print("损失:",OrderProfit());
                 pass=0;
                 
                  OrderDelete(OrderTicket(), Red);
                     e = GetLastError();
                     Print(OrderTicket(),"修改二11111所有订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                     if(e>0){
                        
                        if(OrderType()!=1 || OrderType()!=5 ||OrderType()!=3){
                             OrderClose(OrderTicket(),0.1,Ask+3*Point,3,Red);
                             Print(OrderTicket(),"修改二222所有订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                        
                        }else{
                           OrderClose(OrderTicket(),0.1,Bid+3*Point,3,Red);
                           Print(OrderTicket(),"修改二333所有订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                        }
                        

                                    
                     }
                 
                 return(0);
              
              }

        
              if(OrderProfit()>20 ||OrderProfit()<-20){
                     OrderDelete(OrderTicket(), Red);
                     e = GetLastError();
                     Print(OrderTicket(),"修改二所有订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                     if(e>0){
                        OrderClose(OrderTicket(),0.1,Bid,2,Red);
                        Print(OrderTicket(),"修改二所有订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                                    
                     }
               }
             /*
               
             if(OrderType()==0||OrderType()==2||OrderType()==4){
                            
              if(OrderProfit()>20 ||OrderProfit()<-20 ){
                     OrderDelete(OrderTicket(), Red);
                     e = GetLastError();
                     Print(OrderTicket(),"修改一所有订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                     if(e>0){
                        OrderClose(OrderTicket(),0.1,Ask,2,Red);
                        Print(OrderTicket(),"修改一所有订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                                    
                     }
               }
             
             } 
             
             
            
             if(OrderType()==1||OrderType()==3||OrderType()==5){
                            
              if(OrderProfit()>20 ||OrderProfit()<-20){
                     OrderDelete(OrderTicket(), Red);
                     e = GetLastError();
                     Print(OrderTicket(),"修改二所有订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                     if(e>0){
                        OrderClose(OrderTicket(),0.1,Bid,2,Red);
                        Print(OrderTicket(),"修改二所有订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                                    
                     }
               }
             
            }    
            
            */
     
        
         } 

      
   
     
     if(pass==0){
     
         return(0);
     }
     

      Price=NormalizeDouble(nowBhPrice,Digits);
      //Print("对于 EURUSD M1当前柱0: ", iOpen("EURUSD",PERIOD_M1,0));
      //Print("对于 EURUSD 当前柱ASK: ", Ask);
      //Print("对于 EURUSD 当前柱Bid: ", Bid);
      //if((nowBmPrice>preBmPriceOne) && (preBmPriceOne>preBmPriceTwo) && nowClosePrice>preClosePrice && Ask>iOpen("EURUSD",PERIOD_H1,1) && iClose("EURUSD",PERIOD_H1,1)>iClose("EURUSD",PERIOD_H1,2) && (Ask - preClosePriceH1)>(preClosePriceH1-tpreClosePriceH1)){           
      if(Ask>iOpen("EURUSD",PERIOD_H1,1) && iClose("EURUSD",PERIOD_H1,1)>iClose("EURUSD",PERIOD_H1,2) && (Ask - preClosePriceH1)>(preClosePriceH1-tpreClosePriceH1)){           
          Print("策略一:",Bid);    
          
          
         for (i=total;i>=0;i--){
            if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
   
            preOrderType=OrderType();
            preTicket=OrderTicket();
            prePriceOpen=OrderOpenPrice();
            preTP=OrderTakeProfit();
            preSL=OrderStopLoss();
            prePriceClose=OrderClosePrice();
            if(Ask<preClosePriceH1){
               Print("策略一盈利:",OrderProfit());
   
                 for (m=total;m>=0;m--){
                  if (OrderSelect(m,SELECT_BY_POS,MODE_TRADES)==false) continue;             
                     
                       if(OrderProfit()<=-7 ){
                              OrderDelete(OrderTicket(), Red);
                              e = GetLastError();
                              Print(OrderTicket(),"策略一订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                              if(e>0){
                                 OrderClose(OrderTicket(),0.1,Bid,2,Red);
                                 Print(OrderTicket(),"策略一订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                                             
                              }
                           }
            
            
                   
               }
              
               pass=0;  
            }
                                
         }
          
                             
          if ( total<6 &&Ask-Price >2 * Point && pass==1 && (nowBmPrice>preBmPriceOne) && (preBmPriceOne>preBmPriceTwo) && nowClosePrice>preClosePrice){
             ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,NormalizeDouble(Ask,Digits)+3*Point,1,NormalizeDouble(Ask,Digits)-400*Point,NormalizeDouble(Ask,Digits)+250*Point,"略一下单",Magic,0,Red);  
             Print(ticket);
             if(ticket<=0){
                  int error=GetLastError();
                  Print("错误:",error);
             }else{
                  OrderSelect(ticket,SELECT_BY_TICKET);
                  OrderPrint();
             }
          }              
     }    
     

                 
      
      //if(nowBmPrice<preBmPriceOne && preBmPriceOne<preBmPriceTwo &&  nowClosePrice<preClosePrice && Bid<iOpen("EURUSD",PERIOD_H1,1) && iClose("EURUSD",PERIOD_H1,1)<iClose("EURUSD",PERIOD_H1,2) && (preClosePriceH1 - Ask)>(tpreClosePriceH1-preClosePriceH1) ){
      if( Bid<iOpen("EURUSD",PERIOD_H1,1) && iClose("EURUSD",PERIOD_H1,1)<iClose("EURUSD",PERIOD_H1,2) && (preClosePriceH1 - Ask)>(tpreClosePriceH1-preClosePriceH1) ){      
            Print("策略二",Bid);
            
            for (i=total;i>=0;i--){
               if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
      
               preOrderType=OrderType();
               preTicket=OrderTicket();
               prePriceOpen=OrderOpenPrice();
               preTP=OrderTakeProfit();
               preSL=OrderStopLoss();
               prePriceClose=OrderClosePrice();
               
               
               
               
               
               if(Bid>preClosePriceH1){
                  Print("策略二盈利:",OrderProfit());
                 for (n=total;n>=0;n--){
                  if (OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;        
                    if(OrderProfit()<=-7){
                    
                      OrderDelete(OrderTicket(), Red);
                         e = GetLastError();
                        Print(OrderTicket(),"策略二订单删除",OrderType(),":",e,"订单总数",OrdersTotal());
                        if(e>0){
                           OrderClose(OrderTicket(),0.1,Ask,3,Red);
                           Print(OrderTicket(),"策略二订单关闭",OrderType(),":",GetLastError(),"订单总数",OrdersTotal());
                                       
                        }
   
                    }
                   
                }   
                   pass=0;
                   
               }
                                
         }
          if ( total<6  && Price-Bid > 20 * Point && pass==1 && nowBmPrice<preBmPriceOne && preBmPriceOne<preBmPriceTwo &&  nowClosePrice<preClosePrice ){
            
              
               ticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,NormalizeDouble(Bid,Digits)-3*Point,1,NormalizeDouble(Bid,Digits)+400*Point,NormalizeDouble(Bid,Digits)-250*Point,"略二下单",Magic,0,Blue);  
               Print(ticket,"pass",pass);
               if(ticket<=0){
                     Print("错误:",GetLastError());
               }else{
                  OrderSelect(ticket,SELECT_BY_TICKET);
                  OrderPrint();
               }     
            
            }
                               
      }

}


热忱回答0


最近热帖

近期热议

  1. javascript——prototype与__proto 9
  2. Mysql 中出现的Data truncated for column 3
  3. 在nginx中使用x-sendfile的解决方案 3
  4. 高版本jQuery面插件实现Ajax上传图片 1
  5. Thinkphp Socket.class.php 类的使用 1
  6. 使用ionic3创建第一个App 0
  7. ios-oc html5 0
  8. nginx.conf 0
  9. 基于ionic3.4.0的项目搭建 0
  10. php 缩略图 0