dont you need to include CPosition too ?
Rodrigo Santhiago Batista Dos Reis:
if(!m_trade.PositionModify(m_position.Ticket(), newSL, m_position.TakeProfit()))
Please use the Code button to insert your code, so we can read it easily.
One way or another, you have to get the ticket number (PositionGetTicket - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5):
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- in a loop by all account positions int total=PositionsTotal(); for(int i=0; i<total; i++) { //--- get the ticket of the next position by automatically selecting a position to access its properties ulong ticket=PositionGetTicket(i); if(ticket==0) continue; //--- get the position type and display the description of the selected position to the journal string type=(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE ? "Buy" : "Sell"); PrintFormat("[%d] Selected position %s #%I64u", i, type, ticket); } /* result: [0] Selected position Sell #2810802718 [1] Selected position Buy #2810802919 */ }

Documentation on MQL5: Trade Functions / PositionGetTicket
- www.mql5.com
The function returns the ticket of a position with the specified index in the list of open positions and automatically selects the position to work...

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I hope someone have a solution:
'Ticket' - undeclared identifier
its used here:
if(!m_trade.PositionModify(m_position.Ticket(), newSL, m_position.TakeProfit()))
also the
trade.mqh
and
Ctrade m_trade;
are ok, since im using in other parts of the code.
but i got this error to compile, any idea?
the error:
'Ticket' - undeclared identifier EAPROJECT.mq5 210 57