MQL5: Is it possible to include custom data with a position when opening a trade?

ceejay1962  

Hi,

I've written an EA that opens positions based on multiple timeframes. As such, I'd like to record which timeframe triggered the trade and save that information with the position. The reason for saving the information is to identify and kill a trade, if it reverses. I've searched around the site and MQL5 reference but can't find anything that would do what I want. I was hoping that there would be a generic option to tack on custom data.

I think I can encode the information I want to save in the comment field, but wondered if there was a better, more generic, way of doing it.

Any suggestions?  Thanks.

Fernando Carreiro  
ceejay1962: I've written an EA that opens positions based on multiple timeframes. As such, I'd like to record which timeframe triggered the trade and save that information with the position. The reason for saving the information is to identify and kill a trade, if it reverses. I've searched around the site and MQL5 reference but can't find anything that would do what I want. I was hoping that there would be a generic option to tack on custom data. I think I can encode the information I want to save in the comment field, but wondered if there was a better, more generic, way of doing it. Any suggestions?  Thanks.

The Comment field can be changed by the broker, so that is not a good idea.

In some of my EAs I also have need to keep track of the time-frame, so I encode it into the Magic-Number.

ceejay1962  
Thanks for the reply. That's a great idea.
Reason: