help please

 
nead help: i want to evaluate the profit results (if have 5 losses in row want to excicute order to stop trade)

have any advice please
 
int losses = 0;
for(int i=HistoryTotal()-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         if(OrderProfit()>0 || losses>=5 ) break;
         if(OrderProfit()<0) losses++;
        }

if (losses >= 5) 
{
	// CLOSE ALL ORDERS HERE
	...
}
Reason: