能够做到一键平仓吗?

 

能够做到一键平仓吗?请教各位高手:怎样做到一键平掉所有仓位仓

 
shouw:

能够做到一键平仓吗?请教各位高手:怎样做到一键平掉所有仓位仓


可以,联系QQ1123321025
 

可以的,可以用下面代码:

void CloseAll()
{
bool Result;
int i,Pos,Error;
int Total=OrdersTotal();

if(Total>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE)
{
Pos=OrderType();
if(Pos==OP_BUY)
{Result=OrderClose(OrderTicket(), OrderLots(), Bid, 5, CLR_NONE);}
if(Pos==OP_SELL)
{Result=OrderClose(OrderTicket(), OrderLots(), Ask, 5, CLR_NONE);}
if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT))
{Result=OrderDelete(OrderTicket(), CLR_NONE);}
//-----------------------
if(Result!=true)
{
Error=GetLastError();
Print("LastError = ",Error);
}
else Error=0;
//-----------------------
}
}
}
return(0);
}

 
shouw:

能够做到一键平仓吗?请教各位高手:怎样做到一键平掉所有仓位仓


请到以下链接下载:一键平仓的EA

https://www.mql5.com/zh/forum/135429/page2

原因: