//*******************************************************
//Считаем профит по BUY
int ProfitBUY(int _magic) {int _BUY = 0; int Total, i; Total=OrdersTotal();
if(Total>0) {for(i=Total-1; i>=0; i--) {if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{if(OrderType()==OP_BUY && _magic == Magic) {_BUY =_BUY + OrderProfit();}}}} return(_BUY);}
//*******************************************************
//Считаем профит SELL
int {int _SELL = 0; int Total, i; Total=OrdersTotal();
if(Total>0) {for(i=Total-1; i>=0; i--) {if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{if(OrderType()==OP_SELL && _magic == Magic) {_SELL =_SELL + OrderProfit();}}}} return(_SELL);}
Запуск ProfitSELL(Magic) и ProfitBUY(Magic), где Magic - магик номер