Download MetaTrader 5
To add comments, please log in or register
Articles can help you to solidify your knowledge. Come and read them!
rudy Van Eekelen
178
rudy Van Eekelen 2015.10.23 14: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! 

honest_knave
970
honest_knave 2015.10.23 15: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); }
/
To add comments, please log in or register