Position close in MQL5

 

Hello,

How should I implement immediate position close in MLQ5?

The only way to close something that I found is SendOrder with request action TRADE_ACTION_REMOVE. But removed pending orders, and not active position. 

 Thanks 

 
If its a buy position, do a sell with same volume and vice versa
 
#include <Trade\Trade.mqh>
CTrade            m_trade;

m_trade.PositionClose(Symbol());
 
 

Hi.

I good like close only  which are open whith specific magicnumber.

 
I'm facing the same problem... I tried to use m_trade.PositionClose(Symbol()); but keeps getting error code 10006. I also tried open a position on the opposite direction but just keeps opening a new operation :(
Reason: