Download MetaTrader 5

if x out of y times =True, return True

To add comments, please log in or register
rudy Van Eekelen
rudy Van Eekelen  



I have this if statement:

if (

(condition 1)

&& (condition 2) 

&& (condition 3)

(up to 20 conditions)




Conditions run from checking a candle direction, volume etc etc. 


This works fine, but I would like to get it a little less picky and enter the trade also if only 18/20 (or maybe even 15/20) conditions are true.


Anybody got some advice on how to do this?


Is there maybe a build in function that easily makes : if x out of y times this is true, return true.


Thanks in advance! 

   int cnt=0;

   if(condition1)  { cnt++; }
   if(condition2)  { cnt++; }
   if(condition3)  { cnt++; }
   if(condition4)  { cnt++; }
   if(condition5)  { cnt++; }
   if(condition6)  { cnt++; }
   if(condition7)  { cnt++; }
   if(condition8)  { cnt++; }
   if(condition9)  { cnt++; }
   if(condition10) { cnt++; }

   if(cnt>=8) { EnterTrade(OP_BUY); }
To add comments, please log in or register