Not a good idea to use comments, brokers can change comments, including complete replacement.
And do you know about any alternative? I tried magic number, but my IDs are too big for integer variable.
That is not very optimal indeed. My EA runs a lot of orders simultaneously, so I would have to keep track which variable is paired with which order. Also some orders can be partially closed and some will be closed fully.
1. Define a structure to describe open position with all your custom extra attributes.
2. Define an array to store such structures.
3. Refresh array on every tick - add new trades, delete old ones etc.
This way you can store as many extra attributes for an open position as you like.
4. Optional - save array to file to prevent data loss so you can load it on init if EA was closed in the meantime.And what if I shorten my IDs. Does magic number carry on when I partially close an order?
- what do you mean by shorten the ID / magic number?
- yes, magic number will remain the same.
- what do you mean by shorten the ID / magic number?
- yes, magic number will remain the same.
Well my own ID that I use now for order identification are too long/big for integer variable (in OrderSend function the magic number parameter is integer). But if I can make them shorter/smaller, so they actually fit into integer variable without overflowing, I can put my ID into magic number and identify my orders that way. And when you said, that they actually stay the same even after partial close, then this seems as a perfectly fine solution.
Well my own ID that I use now for order identification are too long/big for integer variable (in OrderSend function the magic number parameter is integer). But if I can make them shorter/smaller, so they actually fit into integer variable without overflowing, I can put my ID into magic number and identify my orders that way. And when you said, that they actually stay the same even after partial close, then this seems as a perfectly fine solution.
Always use a magic number for the order identification. As said whroeder1 broker can change comments not only at a partial close. The new order (after a partial close) will inherit the magic number.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
In my EA I use comments to identify my orders. However when I partially close an order, it seems, that it closes the old order and opens new order with the remaining lot size, but the comment is no longer there. Is there a way how to carry on the comment when partially closing an order?