# help coding how to calculate totalprofit all posotion >= 10 close;

2825

help me please i want to calculate all profit in order and if all position
totalprofit all posotion >= 10 close;
```bool   result;
double price,OrderProfitCash,OrderProfitPoint,RealProfit;
int    cmd,error;
double TimeOut;

{ TimeOut=0;
while(!IsTradeAllowed()) {if(TimeOut > 50) break;TimeOut++;}
{
cmd=OrderType();
//---- first order is buy or sell
{
while(true)
{// Cal the Profit Point
RefreshRates();
if(cmd==OP_BUY) { price =Bid; OrderProfitPoint =(price-OrderOpenPrice())/Point; }
else            { price =Ask; OrderProfitPoint =(OrderOpenPrice()-price)/Point; }

OrderProfitCash = OrderProfit()+OrderCommission()+OrderSwap();
if(OrderProfitCash <= 0) continue;
//if((TakeProfitPoint > OrderProfitPoint) || !OrderProfitCash) break;
result=OrderClose(OrderTicket(),OrderLots(),price,GetSlippage(),CLR_NONE);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
else { error=0; Print("OrderProfit = ", OrderProfit());RealProfit+=OrderProfit();}

if(error==129 || error==135) RefreshRates();
else break;
}
}
}
else Print( "Error when order select ", GetLastError());
}
Print("Close Profit Order Call, Profit Take =",RealProfit);
return(0);

}```

so hows the coding iam stuck??
3243

if you are talking about the whole positions in the account

you can simply use AccountProfit
2825

qjol:
if you are talking about the whole positions in the account

you can simply use AccountProfit

from every order sireee

3243

in order to use any of the following

The order must be previously selected by the OrderSelect() function.