Download MetaTrader 5

Function that returns the number of consecutive wins

To add comments, please log in or register
Jhenrique Vissotto
263
Jhenrique Vissotto  
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!!!
Ernst Van Der Merwe
4934
Ernst Van Der Merwe  
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);
  }
To add comments, please log in or register