int i;
double profit;
profit=0;
for(i=0;OrdersTotal()>i;i++) {
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if(OrderMagicNumber()==MagicNumber) {
profit=profit+OrderProfit()+OrderCommission()+OrderSwap(); }
}
}
if(Profit>0 && ((NameClose == PercentEquity && profit>=balance*Profit/100)
|| (NameClose == ValueProfit && profit>=Profit))) {
deleteAllPos ();
for(i=0;OrdersTotal()>0;i++) {
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if(OrderMagicNumber(i)==MagicNumber) {
OrderDelete(i); } // или вновь отправляем в deleteAllPos //
}
}
balance = AccountBalance();
int i;
double profit;
profit=0;
for(i=0;OrderTotal()>i;i++) {
if(OrderMagicNumber()==MagicNumber) {
profit=profit+OrderProfit()+OrderCommission()+OrderSwap(); }
}
if(Profit>0 && ((NameClose == PercentEquity && profit>=balance*Profit/100)
|| (NameClose == ValueProfit && profit>=Profit))) {
deleteAllPos ();
balance = AccountBalance();
kitajac