评论

收藏

锁仓代码

avatar 刘静 | 1022 人阅读 | 0 人评论 | 2019-03-10

if (GetbuyLots()>GetsellLots()) lock(OP_SELL);
   if (GetbuyLots()<GetsellLots()) lock(OP_BUY);
   }
   //--------------------------------------------------------------------------*/
   return (0);
}
//+--------------------------------锁仓程序------------------------------+
void lock(int Ordertype) {
   double Price1,Lot1,Price2,Lot2;
   if (Ordertype == OP_BUY) {
      OrderSend(Symbol(), OP_BUY, GetsellLots()-GetbuyLots(), Ask, 3, 0, 0, 0, 0, 0, BlueViolet);
      locked = TRUE;
   }
   if (Ordertype == OP_SELL) {
      OrderSend(Symbol(), OP_SELL, GetbuyLots()-GetsellLots(), Bid, 3, 0, 0, 0, 0, 0, BlueViolet);
      locked = TRUE;
   }
   return (0);
}
//+------------------------------------------------------------------+/
//+-------------------------计算开单数-------------------------------+
int GetOrdersTotal(int intOrderType)
{
int buy=0,sell=0,total=0;
for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)   continue;
      if(OrderSymbol()!=Symbol()) continue;
      //---- check order type
       if(OrderType()==OP_BUY ) {buy++;}         
       if(OrderType()==OP_SELL) {sell++;}
       total++;
     }
if (intOrderType==OP_BUY)  return(buy);   
if (intOrderType==OP_SELL) return(sell);
if (intOrderType==6) return(total);
return(99999);
}
//+------------------------------------------------------------------+
//+-------------------------计算buy下单量---------------------------+
double GetbuyLots()
{
   datetime lasttime=Time[Bars-1];
   double buylots,selllots;
   for(int  i=0;i<OrdersTotal();i++)
      {
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)   continue;
        if(OrderSymbol()!=Symbol()) continue;
        if(OrderType()==OP_BUY)
          {
           buylots=OrderLots()+buylots;
          }
      }

    return(buylots);  
}
//+------------------------------------------------------------------+
//+-------------------------计算sell下单量---------------------------+
double GetsellLots()
{
   datetime lasttime=Time[Bars-1];
   double selllots;
   for(int  i=0;i<OrdersTotal();i++)
      {
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)   continue;
        if(OrderSymbol()!=Symbol()) continue;
        if(OrderType()==OP_SELL)
          {
           selllots=OrderLots()+selllots;
          }
      }

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

""
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则