下载MetaTrader 5

请高人帮忙指点一下,编写的一个锁仓EA ,价格已经触发了没有执行,不知何故?

要添加评论,请登录注册
liyfxm88
6
liyfxm88  

double SCD1=10;
double KCZSD1=500; 
double KCZYD1=500;

int    order;
int    ticket;
double price;

int OnInit()
  {
//---
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  int total=OrdersTotal();

   for(i=0; i<total; i++)
     {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
     {
       price=OrderOpenPrice();
       order=OrderTicket();
     if(OrderType()==OP_BUY)
       {
         if(Ask<price-SCD1*Point)
         {
          ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid-KCZSD1*Point,Bid+KCZYD1*Point,"My order #SCKK",11,0,Green);
          if(ticket<0)
           {
            Print("OrderSend 失败错误 #",GetLastError());
           }
          }
        }
      else if(OrderType()==OP_SELL)
       {
        
         if(Bid>price+SCD1*Point )
         {
          ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-KCZSD1*Point,Ask+KCZYD1*Point,"My order #SCKD",22,0,Red);
          if(ticket<0)
           {
             Print("OrderSend 失败错误 #",GetLastError());
           }
         }
       }
    }
         
         
  }

要添加评论,请登录注册