issue with HistoryDealsTotal()

To add comments, please log in or register
Max Payne
372
Max Payne  

I have found that there is an issue with HistoryDealsTotal() while using the optimization algorithms of the tester.

During a normal backtest everything's fine, but in an optimization session, during the initialization phase of the EA, HistoryDealsTotal() returns the number of deals from the previous run of the EA. Later on, during the trading phase, HistoryDealsTotal() starts at 0 again.

I ran into this issue through the following code snippet:

    // constructor
    void MyClass() {
        _dealCnt = HistoryDealsTotal();  // this is causing trouble!
        _orderCnt = OrdersTotal();
        _positionCnt = PositionsTotal();
        _historyOrderCnt = HistoryOrdersTotal();
        ...
    }

The way around this, is to initialize with 0 instead, but still I would be pleased with an official reply to this issue, because to me it looks like some internal variables are reset too late.

Thanks in advance!

Documentation on MQL5: Trade Functions / HistoryDealsTotal
  • www.mql5.com
Trade Functions / HistoryDealsTotal - Documentation on MQL5
Mahdi Amiri
476
Mahdi Amiri  
Max Payne:

I have found that there is an issue with HistoryDealsTotal() while using the optimization algorithms of the tester.

During a normal backtest everything's fine, but in an optimization session, during the initialization phase of the EA, HistoryDealsTotal() returns the number of deals from the previous run of the EA. Later on, during the trading phase, HistoryDealsTotal() starts at 0 again.

I ran into this issue through the following code snippet:

The way around this, is to initialize with 0 instead, but still I would be pleased with an official reply to this issue, because to me it looks like some internal variables are reset too late.

Thanks in advance!

I know this is old question, but someone may be come across.

Use HistorySelect before calling HistoryDealsTotal.

To add comments, please log in or register