Download MetaTrader 5
To add comments, please log in or register
Order a robot or an indicator for MetaTrader. The Freelance service will help you!
Jhenrique Vissotto
263
Jhenrique Vissotto 2016.08.23 15:06 
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
4723
Ernst Van Der Merwe 2016.08.24 08:23  
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