下载MetaTrader 5
要添加评论,请登录注册
您习惯使用智能手机进行交易吗?MetaTrader 5移动版最适合您!
yue
6
yue 2013.08.03 13:45 
我是想亏10点就平仓(5位数的平台),但是不能用,那位给点意见
int CloseAll()
                       {
            for(int i=0;i<OrdersTotal();i++)
               {
               if(OrderSelect(i, SELECT_BY_POS)==true)
                 {
                  if(OrderType()==OP_BUY)
                    {
                    if((OrderOpenPrice()-Bid)/Point>100)
                      {
                      OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),30,Red);
                       
                      }
                    }
                    {                                
                     if(OrderType()==OP_SELL)
                       {
                       if((Ask-OrderOpenPrice())/Point>=100)
                         {
                        OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),30,Red);
                          
                         }
                       }
                     }
                   }
                 }
               }
Fa Cao
1143
Fa Cao 2014.03.29 03:23  

yizhao803:
我是想亏10点就平仓(5位数的平台),但是不能用,那位给点意见

将for()循环修改一为 for(int i=OrdersTotal()-1;i>=0;i--),这样才可能选中所有的持仓单,并平掉;

若写成for(int i=0;i<OrdersTotal();i++),只能选中持仓单的0,2,4,6....,因为OrdersTotal()是个变数,在for循环中,每次的值不一样。

Hongliang Liu
1196
Hongliang Liu 2014.07.11 03:15  

具体是什么错误呢?

下面代码是有问题的,应该用MODE_ASK,否则SELL单关不掉 

if(OrderType()==OP_SELL)
                       {
                       if((Ask-OrderOpenPrice())/Point>=100)
                         {
                        OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),30,Red);
                          
                         }
                       }

 

 如有问题欢迎加技术群探讨:309856361

/
要添加评论,请登录注册