Retrieving the opening Comments of a closed position

 

When placing an Order using CTrade, I'm adding a comment string in the arguments.

I'd like to retrieve that Comment later, once the position has run its course and hit its TP/SL. I must be looking in the wrong place, however, as the only comment I can seem to find looks something like "sl: 1.12345". That's not my comment.


So far, I've tried HistoryDealGet... to find the deal that closed the position, and get the comment. "sl: 1.12345" Nope...

I've tried using the DEAL_POSITION_ID property of the deal, which (I think?) links it to the original order via the ORDER_POSITION_ID property, and getting the comment of that Order. Still not right. "sl: 1.12345"


Any pointer to put me on the right path will be much appreciated and I thank you for taking a look.

 
ASDDA: I can seem to find looks something like "sl: 1.12345". That's not my comment.

Not a good idea to use comments, brokers can change comments, including complete replacement.

 
William Roeder #:

Not a good idea to use comments, brokers can change comments, including complete replacement.

Thank you for the info. I'll try keeping an array instead.
 
If you are looking for some persistent storage, following options I can think of are available:

TerminalGlobalVariables
Objects on Chart / templates
Database
Text or binary File on disk
Pending orders

Depending on what you need to preserve.

I myself have been using comments, this is very depending on the broker. One of my favs don't touch the comments, so it is safe for me to use them.

But brokers messing with client data is not uncommon, so it's a legitimate concern to use comments as storage.

I like the usage of comments, because it gives a way of creating a stateless EA, without being bound to the execution environment.

Too bad the comments of positions, orders and deals are unreliable in this sense.
Reason: