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

简单的多空EA exp_Amstell



exp_Amstell智能交易系统属于简单的多空网格EA。单量颇大,亏损难免。

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

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

extern int    TakeProfit       = 40;           
extern int    StopLoss         = 40;         
extern double Lots             = 0.01;    
//+------------------------------------------------------------------+
 //| expert initialization function                                   |
 //+------------------------------------------------------------------+
 int init()
   {
 //----
   
//----
    return(0);
   }
 //+------------------------------------------------------------------+
 //| expert deinitialization function                                 |
 //+------------------------------------------------------------------+
 int deinit()
   {
 //----
   
//----
    return(0);
   }
 //+------------------------------------------------------------------+
 //| expert start function                                            |
 //+------------------------------------------------------------------+
 int start()
   {
   int Magic=0;
  
for(int cnt=0;cnt<OrdersTotal();cnt++)
      {
       bool cg = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
         {
          if(OrderType()==OP_BUY)
            {
             if(Bid-OrderOpenPrice()>TakeProfit*Point || OrderOpenPrice()-Ask>StopLoss*Point)//
               {
                cg = OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                return(0); 
               }//StopLoss
            }
           if(OrderType()==OP_SELL)
            {
             if(OrderOpenPrice()-Ask>TakeProfit*Point || Bid-OrderOpenPrice()>StopLoss*Point)//
               {
                cg = OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
                return(0); 
               }
            }
          }
       }
 //----
  int buy = 0, sell = 0;
 //----
    if(!ExistPositions(NULL,OP_BUY))buy=1;
    else if(PriceOpenLastPos(NULL,OP_BUY)-Ask>10*Point)buy=1;
  
   if(!ExistPositions(NULL,OP_SELL))sell=1;
    else if(Bid-PriceOpenLastPos(NULL,OP_SELL)>10*Point)sell=1;  
//----
     if(buy==1)
     cg = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",0,0,Green);
    
    if(sell==1)
     cg = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"",0,0,Red);
 //----
    return(0);
   }
 bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
   int i, k=OrdersTotal();
 
  if (sy=="0") sy=Symbol();
   for (i=0; i<k; i++) {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
       if (OrderSymbol()==sy || sy=="") {
         if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
           if (op<0 || OrderType()==op) {
             if (mn<0 || OrderMagicNumber()==mn) {
               if (ot<=OrderOpenTime()) return(True);
             }
           }
         }
       }
     }
   }
   return(False);
 }
 double PriceOpenLastPos(string sy="", int op=-1, int mn=-1) {
   datetime t;
   double   r=0;
   int      i, k=OrdersTotal();
 
  if (sy=="0") sy=Symbol();
   for (i=0; i<k; i++) {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
       if (OrderSymbol()==sy || sy=="") {
         if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
           if (op<0 || OrderType()==op) {
             if (mn<0 || OrderMagicNumber()==mn) {
               if (t<OrderOpenTime()) {
                 t=OrderOpenTime();
                 r=OrderOpenPrice();
               }
             }
           }
         }
       }
     }
   }
   return(r);
 }

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 简单的多空EA exp_Amstell
上一篇:
下一篇:
分享到:更多 ()