Close Position By Ticket
How can i to close position by ticket? this code close position by Symbol()
Farhad1:
How can i to close position by ticket? this code close position by Symbol()
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 } ***

I only open one trade at a time, so this works for me.
I have the tradeID stored globally (so at the top, "int tradeID;") so it means all functions can access it.
So open a trade as normal:
trade.Sell(0.1);
Then, after opening a trade:
tradeID = trade.ResultOrder();
So to close the only open trade:
trade.PositionClose(tradeID);

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