CTrade.PositionClose and get the price

 

How do I get the close price after calling PositionClose?

trade.PositionClose(ticket);

Print("Close position @", ???);

Thank you

 
Yosi Madsu :

How do I get the close price after calling PositionClose?

Thank you

You should always look at the help:

Access to the last request execution results

 

Result

Gets the copy of the structure of the last request result

ResultRetcode

Gets the code of request result

ResultRetcodeDescription

Gets the code of request result as a string

ResultDeal

Gets the deal ticket

ResultOrder

Gets the order ticket

ResultVolume

Gets the volume of deal or order

ResultPrice

Gets the price, confirmed by broker

ResultBid

Gets the current bid price (the requote)

ResultAsk

Gets the current ask price (the requote)

ResultComment

Gets the broker comment

Documentation on MQL5: Standard Library / Trade Classes / CTrade / Result
Documentation on MQL5: Standard Library / Trade Classes / CTrade / Result
  • www.mql5.com
Result(MqlTradeResult&) - CTrade - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
https://www.mql5.com/en/docs/trading

In this section of the reference material there are functions to return the history of closed positions. I haven't used them myself yet but have seen others mention them in forum posts. The link in the reply above will only give you info on the last position closed. The history functions let you access more/all of the previously closed positions.