Best way to "map" trades?

To add comments, please log in or register
Tucaninho
25
Tucaninho  

Hi all,

I have been playing with MQL4 for few months.
One EA that I wrote reads a file, and based on the file content, it opens, closes or modifes SL and TP.

So far I used an hardcoded magic number, and I used comments to match the ID in the file with the current trade.

Today I started playing with closng partial orders, and I noticed that it deletes the comments and writes "from #" and "to #" on the two parts of the trades.

I was wondering what is the best way to track trades since comments cannot be used in this case. I could use magic numbers, which means that every trade will have a different number.

The pro of this is that I can easily track partially closed trades.

The cons is that every trade will have a different magic number, which makes it hard to run multiple EAs on the same account. Plus the ID must be numeric.

I could keep the mapping in memory but if the EA restarted it would cause issues.

Any suggestion on how to approach it in the best way?

Cheers,
Andrea

William Roeder
20228
William Roeder  
Tucaninho: I noticed that it deletes the comments and writes "from #" and "to #" on the two parts of the trades.

Not all brokers do that (most do not.) Not a good idea to use comments, brokers can change comments, including complete replacement.

Find the highest ticket number, on the symbol, after a partial close. That is the new ticket number.

To add comments, please log in or register