if x out of y times =True, return True

Back to topics list To post a new topic, please log in or register
avatar
9
rudyvaneekelen 2015.10.23 16:34
 

Hi,

 

I have this if statement:

if (

(condition 1)

&& (condition 2) 

&& (condition 3)

(up to 20 conditions)

 )

 EnterTrade(OP_BUY)

 

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! 

avatar
736
honest_knave 2015.10.23 17:01 #
 
   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); }

 

Back to topics list  

To add comments, please log in or register