Assuming the CTrade class of the Standard Library, then...
Operations with positions
Opens a position with specified parameters
Additional methods
Opens a long position with specified parameters
The difference is that the Buy is predetermined to only place Buy/Long market orders, while PositionOpen has an extra parameter for selecting the type of order (ORDER_TYPE_BUY or ORDER_TYPE_SELL).
When in doubt, read the documentation and study the source code for the class in the standard library — ".\MQL5\Include\Trade\Trade.mqh"
Assuming the CTrade class of the Standard Library, then...
Operations with positions
Opens a position with specified parameters
Additional methods
Opens a long position with specified parameters
The difference is that the Buy is predetermined to only place Buy/Long market orders, while PositionOpen has an extra parameter for selecting the type of order (ORDER_TYPE_BUY or ORDER_TYPE_SELL).
When in doubt, read the documentation and study the source code for the class in the standard library — ".\MQL5\Include\Trade\Trade.mqh"
The documentation is not clear for newcomers. Ie.: in it the PositionClose has a 'ticket' parameter which can refer to a specific position (I compared this mentally to a file handle in other programming languages). However, PositionOpen - which seems to be the command with the opposite effect - has zero mentions of this 'ticket', and defines the function with the return type of Bool, but I'm currently looking at some borrowed code where the author puts the return value of PositionOpen into a variable with type 'ulong' and turns out that is the 'ticket'.
- 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 everyone, I hope you're well 🙂,
I'm still a beginner on this famous MQL5 language, but I hope to make progress slowly but surely,
However, I do have a few questions, even though I'm thinking of answering them myself one day in the future, but I can't hide the fact that I'm itching to know if anyone can enlighten me.
what are the substantial differences between these 2 functions? X.PositionOpen() and X.Buy() ?,
How long will they last? How do they react to software crashes?
How can I find out if there are pending orders?
Simple links on the forum are enough for me 🙂
Best Reguards,
ZeroCafeine