Download MetaTrader 5

issue with HistoryDealsTotal()

To add comments, please log in or register
Max Payne
Max Payne 2010.08.02 00:58 

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
Trade Functions / HistoryDealsTotal - Documentation on MQL5
To add comments, please log in or register