What does OrderType() > OP_SELL mean?

 

Hello,


What does OrderType() > OP_SELL mean? There are a few instances in the EA I am working with that have some if conditions with OrderType() > OP_SELL . I understand that OrderType() == OP_SELL means it should be equal to a sell order, and OrderType() != OP_SELL means it should not be equal to a sell order. But what does it mean when OrderType() is greater than OP_SELL ?

Codes from EA :

if(OrderSymbol() != Symbol() || OrderType() > OP_SELL)
         continue;

if(OrderType() > OP_SELL)
         OrderDelete(OrderTicket());
 
anuj71: What does OrderType() > OP_SELL mean? There are a few instances in the EA I am working with that have some if conditions with OrderType() > OP_SELL . I understand that OrderType() == OP_SELL means it should be equal to a sell order, and OrderType() != OP_SELL means it should not be equal to a sell order. But what does it mean when OrderType() is greater than OP_SELL ?

They are examples of very bad coding practices. It assumes to depend on the internal values of enumerations or the value of macros.

That is dangerous, because should those values change, the code would fail. So please, do not copy those bad coding practices.

 
anuj71:

Hello,


What does OrderType() > OP_SELL mean? There are a few instances in the EA I am working with that have some if conditions with OrderType() > OP_SELL . I understand that OrderType() == OP_SELL means it should be equal to a sell order, and OrderType() != OP_SELL means it should not be equal to a sell order. But what does it mean when OrderType() is greater than OP_SELL ?

Codes from EA :

It is checking if the order is a pending order type

Edit:- but yes it is a wrong practice as mentioned in the post#1 as anything above OP_SELL could also be balance order.
 
Fernando Carreiro #:

They are examples of very bad coding practices. It assumes to depend on the internal values of enumerations or the value of macros.

That is dangerous, because should those values change, the code would fail. So please, do not copy those bad coding practices.

Ok but i am still confused? what does OrderType() > OP_SELL mean?. OrderType() > OP_SELL means all OP_BUY orders will goes inside if condition?

 
Navdeep Singh #:
It is checking if the order is a pending order type.

OrderType() > OP_SELL will check if there any Sell Pending order or Buy pending order or any pending order?

 
anuj71 #:

OrderType() > OP_SELL will check if there any Sell Pending order or Buy pending order or any pending order?

Yes but not correct method, please check my post again, I edited it
 
anuj71 #: Ok but i am still confused? what does OrderType() > OP_SELL mean?. OrderType() > OP_SELL means all OP_BUY orders will goes inside if condition?

If you look at the table below, all the values greater than the value of OP_SELL, are for pending orders.

So "OrderType() > OP_SELL" is checking for pending orders.

But, please do not program in this way. Use a "switch" operation instead.

Order Properties

ID

Value

Description

OP_BUY

0

Buy operation

OP_SELL

1

Sell operation

OP_BUYLIMIT

2

Buy limit pending order

OP_SELLLIMIT

3

Sell limit pending order

OP_BUYSTOP

4

Buy stop pending order

OP_SELLSTOP

5

Sell stop pending order

Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL4 Reference
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL4 Reference
 
Navdeep Singh #: Yes but not correct method, please check my post again, I edited it
Fernando Carreiro #:

Here is the full code.

Code removed by moderator for including parts obtained from decompilation process.
 
anuj71 #: Here is the full code.
Code removed by moderator for including parts obtained from decompilation process.
Don't request help with code originating from decompiled program. Decompilation violates the terms and conditions, copyright laws and intellectual property rights.


Besides, an answer has already been given ... in post #6

 
  1. Fernando Carreiro #:
    So "OrderType() > OP_SELL" is checking for pending orders.
    But, please do not program in this way. Use a "switch" operation instead.

    Or make your code self-documenting.

    bool OrderIsPending(int type=EMPTY){ return !OrderIsOpened(type); }
    bool OrderIsOpen(int type=EMPTY){ 
       if(type == EMPTY)  type = OrderType();
       return type == OP_BUY || type == OP_SELL; 
    }
    
  2. anuj71: What does OrderType() > OP_SELL mean?

    There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

 
Fernando Carreiro #:
Don't request help with code originating from decompiled program. Decompilation violates the terms and conditions, copyright laws and intellectual property rights.


Besides, an answer has already been given ... in post #6

This not Decompiled. I purchased this EA from original creator a long back.