In an EA, how to determine the difference between a position (filled) and an open order (not filled)
Hi everyone, I am coding my first EA (so MQL4 newbie, but I have decent experience in VBA) and I need a way to distinguish existing positions (filled orders) from pending (unfilled) orders. I imagine there is a way to do this using one of the parameters of the OrderSelect() function, but the documentation and everything else I can find refers to "open orders" without distinguishing between positions and pending orders. Can someone point me in the right direction? I don't need code, just a parameter that will allow me to make that distinction. Thank you!
- One Cancel Other
- Distinguish between long and short orders
- EA Error
jeffkotnik:
Hi everyone, I am coding my first EA (so MQL4 newbie, but I have decent experience in VBA) and I need a way to distinguish existing positions (filled orders) from pending (unfilled) orders. I imagine there is a way to do this using one of the parameters of the OrderSelect() function, but the documentation and everything else I can find refers to "open orders" without distinguishing between positions and pending orders. Can someone point me in the right direction? I don't need code, just a parameter that will allow me to make that distinction. Thank you!
You can do that by looking at the order type with the function OrderType().
Hi everyone, I am coding my first EA (so MQL4 newbie, but I have decent experience in VBA) and I need a way to distinguish existing positions (filled orders) from pending (unfilled) orders. I imagine there is a way to do this using one of the parameters of the OrderSelect() function, but the documentation and everything else I can find refers to "open orders" without distinguishing between positions and pending orders. Can someone point me in the right direction? I don't need code, just a parameter that will allow me to make that distinction. Thank you!
OrderType - Trade Functions - MQL4 Reference
- docs.mql4.com
OrderType - Trade Functions - MQL4 Reference
jeffkotnik #: Hi Fernando, thank you so much. I did read somewhere that OrderType() of OP_BUYSTOP, OP_SELLSTOP, OP_BUYLIMIT, or OP_SELLLIMIT indicates a pending (unfilled) order. Is that your understanding as well? So my code needs to test for those four types, and if OrderType() returns false (I believe OrderType() is boolean), that means it is a position (filled order)?
Did you even read the documentation at the link I provided? Where does it say that it returns a boolean true/false. It states that it returns an "int" with an enumeration of sorts that identifies the order operation properties.
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL4 Reference
- docs.mql4.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL4 Reference
Fernando Carreiro #:
Did you even read the documentation at the link I provided? Where does it say that it returns a boolean true/false. It states that it returns an "int" with an enumeration of sorts that identifies the order operation properties.
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