Selecting a certain open position to modify

 

Hello

i am new here and just learning 

there are already opened positions on mt5

Then my EA  opened several positions to buy for example using trade.Buy which is instance of CTrade

and i want to modify certain position (opened with my EA) based on ticket number,

how can i get the ticket number of open positions that was opened with my EA and not other opened positions.


thank you 

 
no one !?
 

Start to get smart!

Here is the list of all functions: https://www.mql5.com/en/docs/function_indices

Or learn to search (https://www.mql5.com/de/search) as there are lots of code examples ...

Dokumentation zu MQL5: MQL5 Funktionenliste
Dokumentation zu MQL5: MQL5 Funktionenliste
  • www.mql5.com
MQL5 Funktionenliste - Nachschlagewerk MQL5 - Nachschlagewerk über die Sprache des algothitmischen/automatischen Handels für MetaTrader 5
 
max s:

Hello

i am new here and just learning 

there are already opened positions on mt5

Then my EA  opened several positions to buy for example using trade.Buy which is instance of CTrade

and i want to modify certain position (opened with my EA) based on ticket number,

how can i get the ticket number of open positions that was opened with my EA and not other opened positions.


thank you 

You need to be able to identify which positions your EA opened - usually one can set a unique magic number at the time of opening to make it easy.

Once that is known, use the Position functions - loop through the positions and select the ones you want - read all the documentation to get an idea.

The standard documentation does not seem to have examples but I wrote something similar for another query, so you can look at that to see how to construct the loop:

https://www.mql5.com/en/forum/429908#comment_41190517


https://www.mql5.com/en/docs/trading/positiongetticket

Documentation on MQL5: Trade Functions / PositionGetTicket
Documentation on MQL5: Trade Functions / PositionGetTicket
  • www.mql5.com
PositionGetTicket - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5