Position CloseBy

 
This function within the CTrade class is buggy! When running strategy tester the closing prices for some instruments are hugely incorrect. Like EURCAD can be closed at USDJPY prices. This generates false tester results that inflate a strategy's performance.
 
Reminds this reason.

Forum on trading, automated trading systems and testing trading strategies

Wrong symbol for Pending Order ticket during EA backtesting

fxsaber, 2019.05.29 22:30

Try this

//+------------------------------------------------------------------+
//| Modify specified pending order                                   |
//+------------------------------------------------------------------+
bool CTrade::OrderModify(const ulong ticket,const double price,const double sl,const double tp,
                         const ENUM_ORDER_TYPE_TIME type_time,const datetime expiration,const double stoplimit)
  {
//--- check stopped
   if(IsStopped(__FUNCTION__))
      return(false);
//--- clean
   ClearStructures();   
   m_request.symbol = ::OrderSelect(ticket) ? ::OrderGetString(ORDER_SYMBOL) : NULL;
//--- setting request
   m_request.action      =TRADE_ACTION_MODIFY;
   m_request.magic       =m_magic;
   m_request.order       =ticket;
   m_request.price       =price;
   m_request.stoplimit   =stoplimit;
   m_request.sl          =sl;
   m_request.tp          =tp;
   m_request.type_time   =type_time;
   m_request.expiration  =expiration;
//--- action and return the result
   return(OrderSend(m_request,m_result));
  }
 
fxsaber:
Reminds this reason.

I took your advice and did this, and it worked. Thanks.

position_close_by

Reason: