Learning logic - page 8

 
Victor!!! HAPPY BIRTHDAY! All the best!!!
 
poruchik:
Victor!!! HAPPY BIRTHDAY! All the best!!!

Thank you, Although I'm already 8 minutes into the new day.
 
Vinin:

Thank you, though I have 8 minutes into the new day.
To wish you good health and stability in life is never too late, take care Victor, and hello !
 
Mathemat:
Pardon the off-topic: drknn, does logic help you in taming the Fora?


Sometimes it helps to make the code shorter. When I saw this shorthand in Kim's trawl, I was thrilled. And in general, logic doesn't tell you where the truth lies, but it tells you where the truth isn't - this allows you to narrow down and narrow down your search and as a result reveal the truth as an irreducible remainder.

 
drknn:
Mathemat:
Pardon the off-topic: drknn, does logic help you in taming the Fora?

Sometimes it helps to make the code shorter.

Puncture #2. Logic (logic) and brevity have little correlation.

A prime example straight out of MQL, which, by the way, many people are not squeamish about using.

if (OrderType() <= 1)

That's not logic -- that's killing it. It's also a potential breeding ground for implicit errors.

 

The condition is met if it is not a limit/stop order. What is the potential error? Just can't see the context.

Generally speaking, for such variables like "enumerations", it's really not a good idea to use inequalities... It's better to specify identifiers explicitly so we don't have to guess.

 

It's just one of those rakes that makes life a lot easier.

And the rule of thumb is simple -- you can't be attached to absolute values of constants.

The potential pitfall is that

1. You cannot theoretically exclude the possibility of changing absolute values of constants because there is no numbering logic in principle.

2. the value of OrderType() if the order has not been selected is undocumented :)

3. The condition is nontrivial - i.e. let's say we forgot about MQL for half a year, came back, looked it up, looked at the wrong constants and, as a consequence, got the logic wrong.

____________

How about this?

if (OrderType() % 2)
{
   //...
}
 

Similarly, it's a nonsense condition, although technically it might be correct at the moment.

My arguments would be about the same: OP_BUYXXX are mnemonic constant identifiers, which are entered for a reason, but to make fewer errors. That's why it's better to use these identifiers.

 
Yes. And the condition -- "if any type of sell order ".
 

For sale after all?

Well, well. We have a logical operand inside, and I misread it. It turns out it's true when

OrderType() % 2 != 0

- Is that it?

Well, then it's bullshit squared. The code is unreadable :)