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); } //+-------------------------------------------------------------- |
锁仓代码
回复:0 浏览:599
- 楼主admin 圈主
- 2019-05-05 04:50