Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 525

 
Vladislav Andruschenko:
If you specified rost without a value, it defaults to false

Can you explain how this relates to my post? I don't understand it at all.

 
novichok2018:

Can you explain how this relates to my post? Because I don't understand it at all.

You asked. Will all conditions that don't equal true get in. You only have two checks. But if the check is not true, then the check is false. The second line doesn't matter because rost = bool and can only take 2 values and is false by default
 
novichok2018:

Good afternoon!

Question on mcl4 syntax: if I set a flag like this:

then the if(!rost) condition will catch only the condition for rost=false or all conditions not falling under rost=true?

Thanks.

Just don't forget to initialize "rost". In your fragment if cl2=cl1 or cl2=op1 then "rost" is whatever
 
Vladislav Andruschenko:
You asked. Will all conditions that are not true get caught. You only have two checks. But if the check is not true, then the check is false. The second line doesn't matter because you have rost = bool and can only take 2 values and it defaults to false

So, all conditions not falling under the true condition will automatically be false and so the if(!rost) entry will capture both the condition (op1>cl2 && cl1<cl2) and the condition (op1<cl2 && cl1>cl2).Right?

 
Maxim Kuznetsov:
just don't forget to initialise "rost".

How?

 
novichok2018:

So, all conditions not falling under the true condition will automatically be false and so the if(!rost) entry will capture both the condition (op1>cl2 && cl1<cl2) and the condition (op1<cl2 && cl1>cl2).Right?

Yes.
If rost is declared without value, it will always be equal to the last value at global level.

You specified too little data and incomplete code to give a specific answer.
 
novichok2018:

How?

Bool rost=false;
 
Vladislav Andruschenko:
Bool rost=false;

But I just want to avoid a situation where !rost captures all conditions for rost != true. So I did not initiate Bool rost=false at global level, but initiate onTick() separately for false and separately for true. Perhaps, to avoid confusion, it is better to set conditions not if(rost) and if(!rost) but if(rost==true) and if(rost==false) ?

Or then introduce another fla that restricts the conditions of !

 
novichok2018:

But I just want to avoid a situation where !rost captures all conditions for rost != true. So I did not initiate Bool rost=false at global level, but initiate onTick() separately for false and separately for true. Perhaps, to avoid confusion, it is better to set conditions notif(rost) and if(!rost), but if(rost==true) and if(rost==false) ?

Absolutely identical entries.

 
Artyom Trishkin:

Absolutely identical entries.

This correspondence just shows that in my caseif(!rost) is not the same asif(rost==false). Becausethere is a separate condition forfalse.

Reason: