CTrade.PositionClose() New comment DeltaElectronics 2019.08.02 20:19 With reference to this page:https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradepositionclose, I want that once a deal is just closed whit this chunk of code: int posOpened = PositionsTotal(); for (int i=0; i<posOpened;i++) { ticket = PositionGetTicket(i); print("Opened order ticket no.: "+IntegerToString(ticket)+" closed"); m_trade.PositionClose(ticket); } I want adeguately catch the closing events in onTradeTransaction() events of my robot; i.e, referring to it: void OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) { //--- string reason; long deal_entry =0; double deal_profit =0.0; double deal_volume =0.0; string deal_symbol =""; long deal_magic =0; long deal_reason =-1; long deal_type =-1; datetime time; string tipo; ENUM_TRADE_TRANSACTION_TYPE type=trans.type; switch (type) { case TRADE_TRANSACTION_DEAL_ADD: deal_entry= HistoryDealGetInteger(trans.deal,DEAL_ENTRY); deal_profit=HistoryDealGetDouble(trans.deal,DEAL_PROFIT); deal_volume=HistoryDealGetDouble(trans.deal,DEAL_VOLUME); deal_symbol=HistoryDealGetString(trans.deal,DEAL_SYMBOL); deal_magic =HistoryDealGetInteger(trans.deal,DEAL_MAGIC); deal_reason=HistoryDealGetInteger(trans.deal,DEAL_REASON); deal_type =HistoryDealGetInteger(trans.deal,DEAL_TYPE); switch(deal_entry) { .... } break; } } I want to add the code in order to adequately handling such event. Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionClose www.mql5.com Successful completion of the PositionClose(...) method does not always mean successful execution of the trade operation. It is necessary to check the result of trade request (trade server return code) using ResultRetcode... New comment
With reference to this page:https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradepositionclose, I want that once a deal is just closed whit this chunk of code:
I want adeguately catch the closing events in onTradeTransaction() events of my robot;
i.e, referring to it:
I want to add the code in order to adequately handling such event.