Close Position By Ticket

Farhad1  
How can i to close position by ticket? this code close position by Symbol()

#include <Trade\Trade.mqh>
CTrade            m_trade;


onticket()
{

m_trade.PositionClose(Symbol());

}
Vladimir Karputov  
Farhad1:
How can i to close position by ticket? this code close position by Symbol()

Code Close all positions

***
//+------------------------------------------------------------------+
//| Close all positions                                              |
//+------------------------------------------------------------------+
void CloseAllPositions()
  {
   for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of current positions
      if(m_position.SelectByIndex(i))     // selects the position by index for further access to its properties
         m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
  }
***
Close all positions
Close all positions
  • www.mql5.com
Closing positions when reaching a profit level
Reason: