ORDER_POSITION_ID - page 17

 

OrderGetInteger - works only with pending orders in the market

HistoryOrderGetInteger - works with filled orders in the history

 

If anyone else is interested, the code, executable and EA log file are attached.

MT-5 FORTS

Conclusions:

1. Until the order is completely executed or removed, there is NO history on it.

The ORDER_POSITION_ID for the partially executed order is not set.

Thank you all, I got it.

Files:
Test_orders.zip  26 kb
 
йSerj_Che:
HI 0 10:29:25.468 Trades : exchange buy 2.00 SBRF-9.14 at market
JE 0 10:29:25.531 Trades : accepted exchange buy 2.00 SBRF-9.14 at market
NM 0 10:29:25.562 Trades : exchange buy 2.00 SBRF-9.14 at market placed for execution in 88 ms
MN 0 10:29:25.562 Trades : deal #4522433 buy 2.00 SBRF-9.14 at 6903 done (based on order #4988264)
IE 0 10:29:26.640 Trades : exchange sell 2.00 SBPR-9.14 at market
DL 0 10:29:26.734 Trades : accepted exchange sell 2.00 SBPR-9.14 at market
MQ 0 10:29:26.734 Trades : exchange sell 2.00 SBPR-9.14 at market placed for execution in 92 ms
KF 0 10:29:26.734 Trades : deal #4522434 sell 1.00 SBPR-9.14 at 5255 done (based on order #4988265)

DK 0 10:29:26.734 Trades : deal #4522435 sell 1.00 SBPR-9.14 at 5255 done (based on order #4988265)

now it's a partial execution.

Guys, come on, this listing shows that one order (#4988265) was executed by two trades (#4522435 &#4522434) and has nothing to do with a partial execution.

Here is how it works. Let's say we want to buy 50 VTBR-9.14 contracts at the market. We can buy only from liquidity providers, those guys who put limit sell orders. Their level and volume can be seen in the upper half of the cup. Let's look at it:

We place a buy order. Our order can only be executed by 4 different sellers. We can see that we can buy 1 contract at 3874, 40 contracts at 3875, 1 contract at 3876 and 28 contracts at 3877. It means that our order would be filled by 4 sellers at once by 4 deals:

Transaction #
Price

Volume/

available volume.

Total

Volume

Time
1
3874
1/1
112:21:341
2
3875
40/40
4112:21:351
3
3876
1/1
4212:21:363
4
3878
8/28
5012:21:365

Pay attention to the time. The time of making a trade does not necessarily coincide with the time of placing an order. Let me give one more example to make it clearer:

Partial execution.

Suppose we want to buy 100 contracts VTBR-9.14 at a price no worse than 3873. We set BuyLimit for 100 contracts at the level of 3873. However, by the time we place the order, there are already several sellers that sell their contracts at a better price than the one specified in our order:

Volume
Price
1
3871
3
3872
1
3872
39
3872
263872

Immediately after the placing of this limit order, 5 trades will take place, which will partly execute our limit order. in the amount of 70 contracts (1+3+1+39+26).

The executed trades will go into transaction history and the Limit order itself will still be active and will be visible in the "Trade" tab as it is:

Once our order merges limit orders from the opposite direction, its price will be the best offer for those wishing to sell their contracts:

Volume
Price
30 (This is our bid)
3873
2 (other participants' offers are worse)
3872
12
3871

Since our offer is better and the market is liquid, our order will be filled by other market participants with opposite, market or pending orders.

After a while the order will be filled and will go to the "History".

If we analyze the whole process in terms of time, the following will be obtained:

1. We set a Limit order. Its setting time corresponds to ORDER_TIME_SETUP_MSC.

2. Trades initiated by this order start to trigger. These trades are immediately added to the history. The order itself is still in the "Trade" tab and looks as it is shown in the figure above.

3. After a while all the deals trigger, the order gains the necessary volume and is moved into the orders history. Its execution time ORDER_TIME_DONE generally corresponds to the last trade executed.

The order hasn't reached the necessary volume due to some reasons (lack of liquidity, expiration of the order). In this case, it will be moved to the history in the state "partially executed". This means that not all of the requested volume will be executed by trades.

Note the screenshot of this order:

The order was executed within 25 seconds (!) and all this time it was in the tab of active orders. And only the last trade was moved to history. Its ORDER_TIME_DONE, respectively, is now equal to the time of the last trade.

 

P/S As I promised (regarding the publication of the servicedesk response).

I will not get an answer from Service Desk because I withdrew my application as it was no longer needed.

I thank komposter for his proposal to write a test EA with

I will keep you up to date and provide you with detailed logs.

 
papaklass:

All right!? Don't you want to thank Integer, who was with you all evening and made you THINK?

Help yourself after such an attitude...

Do you want to continue?
 
papaklass:

All right!? Don't you want to thank Integer, who was with you all evening and made you THINK?

Help yourself after such an attitude...

That was his fault, you shouldn't have helped him think, you should have done it for him.
 
sandex:
That's his mistake, he should not have helped to think, but did it for him.

sandex:

you are looking in the wrong part,OrderGetInteger(ORDER_POSITION_ID) - you are trying to look in the part that was not involved in opening/modifying/closing the position

you need to look like this HistoryOrderGetInteger(ticket,ORDER_POSITION_ID)

-----------------

Your comment?

Do you want to continue?

 
Mikalas:

sandex:

you are looking in the wrong part,OrderGetInteger(ORDER_POSITION_ID) - you are trying to look in the part that was not involved in opening/modifying/closing the position

you need to look like this HistoryOrderGetInteger(ticket,ORDER_POSITION_ID)

-----------------

Your comment?

Do you want to continue?

Why? Why are you doing this? Like the man wrote nonsense? It wouldn't be nonsense if you hadn't written your own nonsense. You wrote that the order entry appears in the order history and it is still in the market.

Do you want to continue?

 

Completion, I think, is the last one.

No forum I've ever participated in before or am participating in

There is no such attitude of forum users to each other!

A forum is a community of like-minded people solving (discussing)

It is a community of like-minded people who can work together to solve problems and help each other out.

All people are DIFFERENT - one captures the essence of the question on the fly, and the other needs time,

to understand it.

Think about it at your leisure!

P / S And I thank Yurich and komposter, precisely because.

I said thank you to Yurich and komposter because they did not say anything unnecessary.

To a man (even if he's wrong or mistaken).

They are an example of real forum users!

 
papaklass:

I'm already seated in the parterre. Looking forward to it.... :)

Sasha, this is a very comfortable position to get a kick out of...