- int start()
- {
- bool result;
- double price;
- int cmd,error;
- int ordersTotal=OrdersTotal();
-
- if(IsTradeAllowed()) Print("允许交易");
- if(!IsTradeAllowed()){Print("不允许交易!");return(0);}
-
- //for(int i =0;i =0;i--)//正确for循环
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
- {
- cmd=OrderType();
- if(cmd==OP_BUY || cmd==OP_SELL)
- {
- if(cmd==OP_BUY)
- price=MarketInfo(OrderSymbol(), MODE_BID);
- else
- price=MarketInfo(OrderSymbol(), MODE_ASK);
- result=OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
- if(result!=TRUE)
- { Print("多空订单平仓失败,脚本终止,错误代码 ",GetLastError()); break;}
- }</p> else
- {
- result=OrderDelete(OrderTicket());
- if(result!=TRUE)
- {Print("删除挂单失败,脚本终止,错误代码", GetLastError());break;}
- }
- }
- else { Print( "选择订单失败,脚本终止,错误代码", GetLastError(),",i循环至",i);result=false;break;}
- }
- if(result)Print("成功平仓所有多空订单及删除所有挂单");
return(0);
- }
复制代码
<font color="red">for(int i =0;i =0;i--)//正确for循环
不知第一个为错在哪里?
已解决,参考这里:
http://www.520fx.com/thread-36749-1-1.html |