Hi everyone!
How can I know the ticket or de ID of a position across multiple pairs? What I want to do is to implement a trailing stop based on the last position that was opened.
For example, if the last position is +50 pips, then move the stop loss to break even for that position and all the other positions should have the stop at that level.
Once it makes another +50 pips, move the stoploss of all positions +50. Its not a trailing stop with a distance of +50 pips constantly.
Thank you in advance for your advices!
PS
When you use
PositionsTotal()
it returns the number of opened positions. The oldest position has index 0. Let's imagine you have 6 positions opened
int num_pos = PositionsTotal(); ulong pos_ticket = PositionGetTicket( num_pos - 1 );
In this case pos_ticket gives you the ID of the most recent position. This is assuming you have only have positions opened for one symbol
When you use
it returns the number of opened positions. The oldest position has index 0. Let's imagine you have 6 positions opened
In this case pos_ticket gives you the ID of the most recent position. This is assuming you have only have positions opened for one symbol
Is the ID of the Position (CPositionInfo::Indentifier) the same as the ticket number ?
Answered here: https://www.mql5.com/de/docs/constants/tradingconstants/positionproperties
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone!
How can I know the ticket or de ID of a position across multiple pairs? What I want to do is to implement a trailing stop based on the last position that was opened.
For example, if the last position is +50 pips, then move the stop loss to break even for that position and all the other positions should have the stop at that level.
Once it makes another +50 pips, move the stoploss of all positions +50. Its not a trailing stop with a distance of +50 pips constantly.
Thank you in advance for your advices!
PS