📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    锁仓代码

    刘静 LV5
    2019-03-10 · 1625 阅读
    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);  
    }
    //+--------------------------------------------------------------

    ""
    还没有人打赏,支持一下
    回复

    举报

     
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服