Download MetaTrader 5

Confused about OrderSend vs PositionOpen

To add comments, please log in or register
juxeii
88
juxeii  

Hello,

I really don't get the difference between the OrderSend() and PositionOpen() Methods.

1) With both it is possible to open positions?

2) If I'm not using pending orders at all, why would I need to use OrderSend()?

3) Why not always using the OrderSend() method for all kinds of request? Why bothering with PositionOpen()?

I've read the article https://www.mql5.com/en/articles/211, but there is no explanation for this issue.


Thanks for help, much appreciated

Juergen

Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
Trade Functions / OrderSend - Documentation on MQL5
Rashid Umarov
Admin
11993
Rashid Umarov  
juxeii
88
juxeii  
Rosh:
The article Orders, Positions, and Deals in MetaTrader 5 might help you.

Hello Rosh,

sorry, but I did mention that article in my post.

In this article there is no explanation about the difference between OrderSend() and PositionOpen(), so the question still bothers me :-(

My guess is that PositionOpen() translates somehow into OrderSend() with predefined values.

It's sad that there is not much of an explanation source.


Best regards

Juergen

Rashid Umarov
Admin
11993
Rashid Umarov  
You confuse OrderSend() from Trade Functions and PositionOpen from the CTrade class in Standard Library.

juxeii
88
juxeii  
Rosh:
You confuse OrderSend() from Trade Functions and PositionOpen from the CTrade class in Standard Library.

I guess so :-)

But what is the difference?

If one calls PositionOpen(), then there is an open position for that symbol?!

Now, the question is, if there is another call PositionOpen() on the same symbol...what would happen?

I guess this gives an error.

But one can call OrderSend() many times.

All I would like to know, what is the proper method to open a position on say EUR/USD?

I can call PositionOpen() to do this or OrderSend() to achieve the same!

The only difference I see, is that PositionOpen() has less parameters.

Sorry, I'm still confused since both methods achieve the same.

Best regards

Juergen


Amir Yacoby
1195
Amir Yacoby  
juxeii:

I guess so :-)

But what is the difference?

If one calls PositionOpen(), then there is an open position for that symbol?!

Now, the question is, if there is another call PositionOpen() on the same symbol...what would happen?

I guess this gives an error.

But one can call OrderSend() many times.

All I would like to know, what is the proper method to open a position on say EUR/USD?

I can call PositionOpen() to do this or OrderSend() to achieve the same!

The only difference I see, is that PositionOpen() has less parameters.

Sorry, I'm still confused since both methods achieve the same.

Best regards

Juergen


OrderSend() is the MQL5 command for sending an order. If you use the standard class library, you should use PositionOpen() which is a wrapper around OrderSend and it performs some more checks for you regarding the order (checks the IsStopped flag and the correctness of your parameters and also takes care of logging the order). So, the object oriented standard way is to use PositionOpen() of CTrade. BTW, have a look at the code of CTrade PositionOpen and you'll get the answer.
Create your own Market Watch using the Standard Library Classes
  • 2010.12.28
  • Dmitriy Skub
  • www.mql5.com
The new MetaTrader 5 client terminal and the MQL5 Language provides new opportunities for presenting visual information to the trader. In this article, we propose a universal and extensible set of classes, which handles all the work of organizing displaying of the arbitrary text information on the chart. The example of Market Watch indicator is presented.
juxeii
88
juxeii  
amir_avatar:
OrderSend() is the MQL5 command for sending an order. If you use the standard class library, you should use PositionOpen() which is a wrapper around OrderSend and it performs some more checks for you regarding the order (checks the IsStopped flag and the correctness of your parameters and also takes care of logging the order). So, the object oriented standard way is to use PositionOpen() of CTrade. BTW, have a look at the code of CTrade PositionOpen and you'll get the answer.

Ah, many thanks for this hint.

After regarding the source code of PositionOpen(), many questions have gone ;-)

But one thing remains, and I guess this was the origin of my problem:

To me the name "PositionOpen" is misleading, because one cannot have more than one position of a symbol.

So one could think that two calls on PositionOpen would break this rule.

As far as I can see, this is not true, but the semantic is still misleading.


So again, thank you very much.

Now I can create my DLL interface without any ambiguity.

Best regards

Juergen

okwh
1633
okwh  

as I lknow:
now,in MQL5,  order is related with command or request send to server for a possible trade with current price or limited price .  position means  net-trade opened, closed or sure to open with current buy or sell price.
 and An order is a request to conduct a transaction, while a position is a result of one or more deals.
so  order is a possible trade befor trading, a request or a pending order, can be sent or opened, modified,and deleted, deal is result of successed trade command or request,  
 position is net inevitable net-trade for one instrument symble,  can be opened, modified, and closed,but not delete.

 Do not mix them in MQL5 and in life.   the problem is  the name positionopen() not so perfect.
or order like action influence future,    deal is deal,     position like the state now

To add comments, please log in or register