有您的持续关注
我们会做得更好

平掉所有订单的函数模块又一完整写法



平掉所有订单的又一完整写法模块
int CloseEverything()
{
double myAsk;
double myBid;
int myTkt;
double myLot;
int myTyp;
int i;
bool result = false;
for(i=OrdersTotal();i>=0;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

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 平掉所有订单的函数模块又一完整写法
上一篇:
下一篇:
分享到:更多 ()

评论 抢沙发

评论前必须登录!