Function that returns the number of consecutive wins

 
Hi guys!

I’m looking for a function that returns the number of consecutive profitable trades until X victories. When the number of profitable trades hits the X value, so the count is restarted.

If someone can help me... thx!!!
 
printf("Total consecutive profitable orders: %d",OrdersTotalProfitable());

int OrdersTotalProfitable()
  {
   int count=0,total=OrdersHistoryTotal();
   for(int i=total-1;i>=0;i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==_Symbol)
        {
         if(OrderProfit()>0.0)
            count++;
         else
            break;
        }
//---
   return(count);
  }