您需要 登录 才可以下载或查看,没有帐号?注册
函数执行持仓单全部平仓及挂单全部删除。
int CloseEverything()
{
double myAsk;
double myBid;
int myTkt;
double myLot;
int myTyp;
int i;
bool result = false;
for(i=OrdersTotal();i i--)
{
OrderSelect(i, SELECT_BY_POS);
myAsk=MarketInfo(OrderSymbol(),MODE_ASK);
myBid=MarketInfo(OrderSymbol(),MODE_BID);
myTkt=OrderTicket();
myLot=OrderLots();
myTyp=OrderType();
switch( myTyp )
{
//Close opened long positions
case OP_BUY :result = OrderClose(myTkt, myLot, myBid, Slippage, Red);
break;
//Close opened short positions
case OP_SELL :result = OrderClose(myTkt, myLot, myAsk, Slippage, Red);
break;
//Close pending orders
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT:
case OP_SELLSTOP :result = OrderDelete( OrderTicket() );
}
if(result == false)
{
alert( Order , myTkt , failed to close. Error: , GetLastError() );
Print( Order , myTkt , failed to close. Error: , GetLastError() );
Sleep(3000);
}
Sleep(1000);
} //for
} // closeeverything复制代码
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!