一键平仓脚本执行错误 算是老问题了 可怎么解决呢?(源码)
回复:0 浏览:65
- 楼主admin 圈主
- 2019-05-05 10:22
牛板的一键平仓脚本全商品版 怎么都执行不了 返回错误4051或4109
到底出错在哪里?
代码稍有改动(没改动的也不行):
- int start()
- {
- int tick[200];
- int PingFlag=0,SlipPoints=3;
- int j=0;
- for(int i=0;i=0;i--)
- {
- OrderSelect(tick, SELECT_BY_TICKET);
- if(OrderType()==OP_BUY)
- {
- if(OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),SlipPoints)==false)
- {
- PingFlag=1;
- Print("多头平仓失败"+GetLastError());
- }
- }
- OrderSelect(tick, SELECT_BY_TICKET);
- if(OrderType()==OP_BUYSTOP)
- {
- if(OrderDelete(OrderTicket(),CLR_NONE)==false)
- {
- PingFlag=1;
- Print("多头挂单撤销失败"+GetLastError());
- }
- }
- if(OrderType()==OP_BUYLIMIT)
- {
- if(OrderDelete(OrderTicket(),CLR_NONE)==false)
- {
- PingFlag=1;
- Print("多头挂单撤销失败"+GetLastError());
- }
- }
- if(OrderType()==OP_SELL)
- {
- if(OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),SlipPoints)==false)
- {
- PingFlag=1;
- Print("空头平仓失败"+GetLastError());
- }
- }
- if(OrderType()==OP_SELLSTOP)
- {
- if(OrderDelete(OrderTicket(),CLR_NONE)==false)
- {
- PingFlag=1;
- Print("空头挂单撤销失败"+GetLastError());
- }
- }
- if(OrderType()==OP_SELLLIMIT)
- {
- if(OrderDelete(OrderTicket(),CLR_NONE)==false)
- {
- PingFlag=1;
- Print("空头挂单撤销失败"+GetLastError());
- }
- }
- }
- }
- if (PingFlag==0)
- {
- alert("平仓完成!");
- }else
- {
- alert("平仓不彻底,再来一次!");
- }
- return(0);}
复制代码 |