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.
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 :
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?
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.
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
- docs.mql4.com
Besides, an answer has already been given ... in post #6
- 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; }
- anuj71: What does OrderType() > OP_SELL mean?
There is no need to create pending orders in code.
-
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.
-
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.
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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 :