Download MetaTrader 5

boolean trade condition...

To add comments, please log in or register
Morgan Morden
685
Morgan Morden  

I am trying to use a boolean statement within my signal paramenters - 

in global variables I have 'USE MA' = True,

I need to insert nested if statement, but it keeps running with errors.. 

In other words I want to add another condition if (and only if) boolean statement on global level is true, otherwise just continue without..

  if ((condition 1) && (condition 2) &&
         
       (if (MA_Filter==True) FastMA=<SlowMA) 

     {
      do this
     }
honest_knave
Moderator
2293
honest_knave  
   if((condition 1) && (condition 2) && (!MA_Filter || (MA_Filter && FastMA<=SlowMA))) 
     {
      do this
     }
It should be <= not =<
Morgan Morden
685
Morgan Morden  
honest_knave:
It should be <= not =<

Thanks but that did not solve the issue..
honest_knave
Moderator
2293
honest_knave  
fabian waldo:

Thanks but that did not solve the issue..

Did you look at the rest of the code I posted? You need to do that, or you could use a ternary operator.
whroeder1
16555
whroeder1  
fabian waldo: In other words I want to add another condition if (and only if) boolean statement on global level is true, otherwise just continue without..
fabian waldo: Thanks but that did not solve the issue..
  1. honest_knave's answer exactly answered your question. Simplified:
    if((condition 1)                   // Condition1
    && (condition 2)                   // and condition2
    && (!MA_Filter || FastMA<=SlowMA)  // and (if filter enabled) condition3
    ) {
       do this
    }

  2. What issue? "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
Morgan Morden
685
Morgan Morden  
honest_knave:

Did you look at the rest of the code I posted? You need to do that, or you could use a ternary operator.


For some reason I missed that... 

It works now, Thanks a lot for the help knave!

To add comments, please log in or register