Download MetaTrader 5

Attach orders per candle

To add comments, please log in or register
dream3r
886
dream3r  

Hello,

I realize that the pending orders don't return the initial OrderOpenTime() and it returns the time when it opens the position (OP_BUY or OP_SELL).

I am doing a code that in each bar open an order (Sell or Buy) and in the max/min of the same candle put a pending order. I would like attach this 2 orders in some way to close it together.

 

Can someone help me on that?

 

Example:

Candle 1: Sell Order (ticket 1) & Buy Pending Order (ticket 2)

Candle 2:  Buy Order (ticket 3) & Sell Pending Order (ticket 4). The Buy Pending Order (ticket 2) it's touched and enter into th market. 

Candle 3: Sell Order (ticket 5) & Buy Pending Order (ticket 6).

.... the others pending orders (tickets 4 and 6) won't be executed. 

 

In this example, I want attach in that way:

Candle 1: Tickets 1 and 2

Candle 2: Ticket 3 and 4

Candle 3: Ticket 5 and 6

 

I also think to assume that the even numbers are the market orders and the odd are the pendings, but....what happen if the spread/market can not put the order and this "system" will be uncounted? 

Thank you in advance 

Dream3r 

Alexander Puzanov
31575
Alexander Puzanov  
You can write bar's time in 'Comment' field or use it as 'Magic number', for example
dream3r
886
dream3r  
f2011:
You can write bar's time in 'Comment' field or use it as 'Magic number', for example
Ok, thank you!! I will do it in that way!
To add comments, please log in or register