| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Lost magic number and comment after partially closing
Does anyone here have a solution about this problem? Let's say you use OrderSend to open 0.5 lots. If you call orderClose to close 0.1 lot. The system would generate another new 0.4 lots order, but your original magic number and comment were lost. Without them, your EA couldn't work together with others on the same symbol. I have to open multiple orders for this problem, wondering if there is anyway to keep them.
Thanks! |
|
|||
|
Lost magic number
No warranty to this code but it has worked for a very long time
int orderToClose = (ticket number of the smaller ticket); int closingTicket = (ticket number of the larger ticket); if (orderToClose != 0 && closingTicket != 0) { bFlag1 = OrderCloseBy(orderToClose, closingTicket); if (bFlag1 == true) { newTicket = 0; // Check for a new ticket for (idx2 = OrdersTotal() - 1; idx2 >= 0; idx2--) { if (OrderSelect(idx2, SELECT_BY_POS, MODE_TRADES)) { s = StringConcatenate("split from #", orderToClose); splitIndex = StringFind(OrderComment(), s, 0); if (splitIndex != -1) { // We found the new ticket number newTicket = OrderTicket(); // Now update the old ticket to the new ticket closingTicket = newTicket; break; } } } } In my opinion MQL4 has it completely backwards on this point. They change the ticket number making it very difficult to find. I hope this helps. Scott |
|
|||
|
Thanks, so it will use "Split from xxx" as the comment of the new orders. I will try it.
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| magic number | forextrend | Metatrader 4 | 31 | 04-11-2008 04:27 PM |
| How do I add magic number or comment to manual order? | waltini | Metatrader 4 | 3 | 11-01-2006 04:57 PM |
| MT4 Magic Number | DeadEye96 | Expert Advisors - Metatrader 4 | 2 | 09-19-2006 10:05 PM |
| magic number | caldolegare | Metatrader 4 | 4 | 03-19-2006 05:28 AM |