Download MetaTrader 5

if in if

To add comments, please log in or register
Alexandru Ionut Comanoiu
621
Alexandru Ionut Comanoiu  

Hi!

I need someone with a bigger and smarter brain.

How can i do something like this:

Add conditions in an "if" only if another condition is true.

//------------------------------------------------------------------------------

if (condition1 && condition2 &&

                if (condition3==true) {condition4 && condition5} &&

                if (condition6==true) {condition7 && condition8)

  )

//------------------------------------------------------------------------------

Hope someone knows this or i'll have to write hundreds line of code.

Mohammad Soubra
27445
Mohammad Soubra  
Alexandru Ionut Comanoiu:

Hi!

I need someone with a bigger and smarter brain.

How can i do something like this:

Add conditions in an "if" only if another condition is true.

//------------------------------------------------------------------------------

if (condition1 && condition2 &&

                if (condition3==true) {condition4 && condition5} &&

                if (condition6==true) {condition7 && condition8)

  )

//------------------------------------------------------------------------------

Hope someone knows this or i'll have to write hundreds line of code.

if (condition1 && condition2)
{
    if (condition3==true)
    {
        if (condition4 && condition5)
        {
            if (condition6==true)
            {
                if (condition7 && condition8)
                {
                    .............................................................;
                    .............................;
                    ...............;
                }
            }
        }
    }
}

Alexandru Ionut Comanoiu
621
Alexandru Ionut Comanoiu  
Mohammad Soubra:

Thanks for the reply, but i think i was'nt too clear. The first "if" should do something if the conditions are ok. But, if the other conditions are true the result should be different. In your example all the conditions have to be met.

To be more specific, the first two conditions in the first "if" are mandatory and the other ones are aplied filters. I don't know wich filter is aplied so i need to check the filters and add conditions to the first "if", only if the filters are active.

Mohammad Soubra
27445
Mohammad Soubra  
Alexandru Ionut Comanoiu:

Thanks for the reply, but i think i was'nt too clear. The first "if" should do something if the conditions are ok. But, if the other conditions are true the result should be different. In your example all the conditions have to be met.

To be more specific, the first two conditions in the first "if" are mandatory and the other ones are aplied filters. I don't know wich filter is aplied so i need to check the filters and add conditions to the first "if", only if the filters are active.

clarify please

Vasyl Nosal
18657
Vasyl Nosal  

I do not know what you want but maybe else will help you.

else
Mohammad Soubra
27445
Mohammad Soubra  
can you post the real code????
Khurram Mustafa
30391
Khurram Mustafa  

you can move if condition every where 

just like true false

if 1 && 2 met result else false result

other ways

if 1 && 2 not met = answer if answer is not met return 

Khurram Mustafa
30391
Khurram Mustafa  
Further more, please show limited code
Alexandru Ionut Comanoiu
621
Alexandru Ionut Comanoiu  

I've done it!

(condition3 and condition6 are extern bool vars)

//--------------------------------------------------------

bool condition4 =true;

bool condition5 =true;

bool condition7 =true;

if (condition3==true)  { condition4 = blah blah.... ;

                                     condition5 = whathev......;}

if (condition6==true)     condition7 = fsdasfwerefdsf;

//--------------------------------------------------------------------------------------

if (condition1 && condition2      && condition4 && condition5  && condition7)

{

do something.....

}

//--------------------------------------------------------------------------------------

if... let's say some filters (condition3 and condition6) are false 4,5,7 are true so they does'nt alter the result. If the filters are true, 4,5,7 are taken in consideration in the if.

Anyway, thanks everyone!

Khurram Mustafa
30391
Khurram Mustafa  
you are welcome
To add comments, please log in or register