Learning logic - page 9

 

Yeah :) I was exaggerating a bit.

Here's another example :) but it's unlikely to work well in MQL, it will work in C++:

for (int i = OrdersTotal(); i--;)
{
   if (!OrderSelect(i - 1, SELECT_BY_POS)) continue;

   //...
}
 
Mathemat:

For sale after all?

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

- Is that it?

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


The code is quite readable. You shouldn't be.
 

To avoid having to decipher what is meant (any sell order), it would make more sense to write out the identifiers of order types. It would be shorter, but much clearer.

In terms of brevity, yes, it is a solution, but not very reliable. The developer does not guarantee that the numerical values of these constants will never change.

 
Mathemat:

To avoid having to decipher what is meant (any sell order), it would make more sense to write out the identifiers of order types. It would be shorter, but much clearer.

In terms of brevity - yes, this is a solution, but not very reliable. The developer does not guarantee that the numerical values of those constants will never change.


That's the problem. It is possible to make a nifty code that suddenly stops working.
 
TheXpert:

Here's another example :) but it's unlikely to work properly in MQL, it will work in C++:

for (int i = OrdersTotal(); i--;)
{
   if (!OrderSelect(i - 1, SELECT_BY_POS)) continue;

   //...
}
I haven't checked it, but I wouldn't write it that way myself.
 
TheXpert:

Yeah :) I was exaggerating a bit.

Here's another example :) but it's unlikely that it will work properly in MQL, it will work in C++:


This is not optimization but perversion... Pardon me, it's a perversion...

A nice little task came to mind: how to swap values between two numeric variables without using the third one. ))

 
Vinin:
You can make a nifty code that suddenly stops working.

That's the whole point - this code is not elegant. This is more elegant:

bool IsActiveType(int orderType)
{
   return (type == OP_BUY || type == OP_SELL);
}

bool IsAnySellType(int orderType)
{
   return (type == OP_SELL || type == OP_SELLLIMIT || type == OP_SELLSTOP);
}

{
   if (IsActiveType(OrderType()))
   {
      //...
   }

   if (IsAnySellType(OrderType()))
   {
      //...
   }
}

denis_orlov:

This isn't optimization, it's perverse... Pardon me...

I recall a nice little task how to swap values between two numeric variables without using the third one. ))

Yeah :) sort of.
 
TheXpert:

That's the whole point - this code is not elegant. This one is more elegant:

Yeah, that's right. The one-line body functions have never been cancelled, they're actually very useful.
 
TheXpert:

That's the whole point - this code is not elegant. This one is more elegant:


I like it. It looks beautiful.
 
TheXpert:

That's the whole point - this code is not elegant. This is more elegant:



You only need to remove function parameters to make it more intricate. If the parameter is not specified, then determine from OrderType() of the order, if it is specified, then by the parameter.

I'm bored here :)))

Reason: