Hi all
I'm trying to find out how I can make my EA stop trading after being stopped out at SL. I found some code on MQL4 that looks usable, but I'm a bit confused about one of the statement, and I'd like to ask you to verify that I understand it correctly. The code can be found in the following mail:
https://www.mql5.com/en/forum/137546
The code is as follows:
<CODE DELETED>
Firstly . . .
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
It looks good, but because there can be at least six different types of orders (OP_BUY, OP_BUYSTOP, OP_BUYLIMIT, OP_SELL, OP_SELLSTOP, OP_SELLLIMIT), I'm a bit confused about what the following statement means:
OrderType() <= OP_SELL
Does this mean that only OP_BUY is less than OP_SELL, and we don't want to check other types of orders from the history file? If that is correct, it would be the same as writing
(OrderType() == OP_SELL || OrderType == OP_BUY)
I know that it is kind of a trivial question, and I could try it out myself, but I'm just a bit confused, because as I understand the comments in the code, it only works on OP_SELL (it states that it avoids the credit orders).
Secondly . . .
Pending order types do not appear in the Order History . . .
( OrderType() <= OP_SELL )
// is the same as . . .
( OrderType() == OP_SELL || OrderType == OP_BUY )
You can see the constant values for OP_BUY OP_SELL etc. here.
This version is more readable . . .
( OrderType() == OP_SELL || OrderType == OP_BUY )
Hi RaptorUK
Thanks for your reply, it clarifies my confusion completely ... and I will try to remember to use the SRC button next time ... :-)
Best regards
G

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
I'm trying to find out how I can make my EA stop trading after being stopped out at SL. I found some code on MQL4 that looks usable, but I'm a bit confused about one of the statement, and I'd like to ask you to verify that I understand it correctly. The code can be found in the following mail:
https://www.mql5.com/en/forum/137546
The code is as follows:
It looks good, but because there can be at least six different types of orders (OP_BUY, OP_BUYSTOP, OP_BUYLIMIT, OP_SELL, OP_SELLSTOP, OP_SELLLIMIT), I'm a bit confused about what the following statement means:
OrderType() <= OP_SELL
Does this mean that only OP_BUY is less than OP_SELL, and we don't want to check other types of orders from the history file? If that is correct, it would be the same as writing
(OrderType() == OP_SELL || OrderType == OP_BUY)
I know that it is kind of a trivial question, and I could try it out myself, but I'm just a bit confused, because as I understand the comments in the code, it only works on OP_SELL (it states that it avoids the credit orders).
Could you please comment on this?
Thanks in advance.
Best regards
G