It's quite common in MQL4 code. OP_BUY is zero; OP_SELL is 1; all pending orders such as OP_BUYLIMIT have IDs from 2 upwards. Therefore, OrderType() <= OP_SELL is a way of saying "if the selected ticket is an open position rather than a pending order..."
It's simpler, though less clear, than (OrderType() == OP_BUY || OrderType() == OP_SELL)
qgmql:
( BTW, the code you are quoting is very bad. See the countless posts on this forum about looping from OrdersTotal()-1 downwards, rather than from zero upwards, when closing orders. )
jjc: It's simpler, though less clear, than (OrderType() == OP_BUY || OrderType() == OP_SELL)
| Write self-documenting code and it's very clear.bool OrderIsPending(void){ return OrderType() >= OP_BUYLIMIT; } bool OrderIsOpen(void){ return !OrderIsPending(); } |
qgmql: less than, equal to sign? Why checking BUY while checking a SELL?
|
|
WHRoeder:
Surely...
bool OrderIsPending(void){ return OrderType() >= OP_BUYLIMIT; } bool OrderIsOpen(void){ return !OrderIsPending(); }
WHRoeder:
"attached file" was given to me to check. if you please highlight the things, for which i must find topics in book. or this EA is having a bad code in all? (BTW its giving positive results to a trader, except one thing that it opens an other trade right after a trade is closed)
jjc: It's simpler, though less clear, than (OrderType() == OP_BUY || OrderType() == OP_SELL) | Write self-documenting code and it's very clear. |
qgmql: less than, equal to sign? Why checking BUY while checking a SELL? |
|
Files:
cashmachine_5min.mq4
9 kb
total = OrdersTotal(); if(total < 1)
Means the EA is incompatible with every other, including itself on other charts and manual trading. order accounting - MQL4 forumfor(cnt = 0; cnt < total; cnt++)
You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register