Different Trailing distance for each position

 

Hello guys

I need help. I want to program EA which will open each order with specific Trailing distance.

The quesion is, where to store this information. For example I can store it in "comment" and OnTick receive Trailing distance for each position from comment, then move it if necesssary. But i think it is not reliable, anything can happne to commnet, even broker can modify it. 

 
Another Idea is to store it in Magic Number
 

The simplest way is a globalscope 2 dimensional array.

First dimension holds the ticket number.

Second the trail distance.

 
Narek Kamalyan: I need help. I want to program EA which will open each order with specific Trailing distance. The quesion is, where to store this information. For example I can store it in "comment" and OnTick receive Trailing distance for each position from comment, then move it if necesssary. But i think it is not reliable, anything can happne to commnet, even broker can modify it. 

Don't use the "comment" field as that can be modified or even cleared by the broker. You will have to keep track of the information locally, just as @Keith Watford suggested in his prior post.

EDIT: Also, I don't recommend using the Magic Number as that is reserved for EA identification and tracking of orders. If you start using it for tracking of trailing stops you will end up with so many Magic Numbers, it will become difficult to track the order history for later analysis.

Keith Watford
Keith Watford
  • 2021.04.04
  • www.mql5.com
Trader's profile
Reason: