Errors, bugs, questions - page 1989

 

The performance of the tester is highly dependent on the trade server.


Tester settings:

Netting USD, Core1 only enabled.


Expert Advisor

#include <TesterBenchmark.mqh> // https://www.mql5.com/ru/code/18804

input int Interval = 60;
input int AmountLastDeals = 5;
input double Lots = 1;

double CorrectLot( const double Lot )
{
  static const double StepVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
  static const double MaxVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
  static const double MinVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);

  const double Vol = StepVol * (int)(Lot / StepVol + 0.5);

  return((Vol < MinVol) ? MinVol : ((Vol > MaxVol) ? MaxVol : Vol));
}
  
void OnTick()
{  
  if (!PositionGetTicket(0))
  {
    if (HistorySelect(0, TimeCurrent()))
    {
      const int Total = HistoryDealsTotal() - 1;

      double SumProfit = 0;
      double SumLots = 0;

      for (int i = Total, Count = 0; (i >= 0) && (Count < AmountLastDeals); i--)
      {
        const ulong Ticket = HistoryDealGetTicket(i);

        if ((ENUM_DEAL_ENTRY)HistoryDealGetInteger(Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT)
        {
          SumProfit += HistoryDealGetDouble(Ticket, DEAL_PROFIT) * (AmountLastDeals - Count);
          SumLots += HistoryDealGetDouble(Ticket, DEAL_VOLUME) * (AmountLastDeals - Count);

          Count++;
        }
      }

      SumLots /= (AmountLastDeals * (1 + AmountLastDeals)) >> 1;

      MqlTradeRequest Request = {0};

      Request.action = TRADE_ACTION_DEAL;

      Request.symbol = _Symbol;
      Request.type = ((Total >= 0) && ((ENUM_DEAL_TYPE)HistoryDealGetInteger(HistoryDealGetTicket(Total), DEAL_TYPE) == DEAL_TYPE_SELL)) ?
                     ORDER_TYPE_SELL : ORDER_TYPE_BUY;;

      Request.volume = (SumProfit >= 0) ? Lots : CorrectLot(SumLots);
      Request.price = SymbolInfoDouble(Request.symbol, (Request.type == ORDER_TYPE_BUY) ? SYMBOL_ASK : SYMBOL_BID);

//      MqlTradeCheckResult CheckResult;
//      if (OrderCheck(Request, CheckResult))
      {
        MqlTradeResult Result;

        const bool AntiWarning = OrderSend(Request, Result);
      }
    }
  }
  else if (TimeCurrent() - PositionGetInteger(POSITION_TIME) >= Interval)
  {
    MqlTradeRequest Request = {0};
    MqlTradeResult Result;

    Request.action = TRADE_ACTION_DEAL;
    Request.position = PositionGetInteger(POSITION_TICKET);

    Request.symbol = PositionGetString(POSITION_SYMBOL);
    Request.type = (ENUM_ORDER_TYPE)(1 - PositionGetInteger(POSITION_TYPE));

    Request.volume = PositionGetDouble(POSITION_VOLUME);
    Request.price = PositionGetDouble(POSITION_PRICE_CURRENT);

    const bool AntiWarning = OrderSend(Request, Result);
  }
}


Result onFIBOGroup-MT5 Server

------
OnTesterInit
i = 0 Pass = 0 OnTester = 7.994 s.: Count = 15925124, 1992134.6 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 1 Pass = 1 OnTester = 7.831 s.: Count = 15925124, 2033600.3 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 2 Pass = 2 OnTester = 7.811 s.: Count = 15925124, 2038807.3 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 3 Pass = 3 OnTester = 7.825 s.: Count = 15925124, 2035159.6 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 4 Pass = 4 OnTester = 7.831 s.: Count = 15925124, 2033600.3 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 5 Pass = 5 OnTester = 7.832 s.: Count = 15925124, 2033340.7 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
iMin = 2 Results[iMin] = 7.811 s.
iMax = 0 Results[iMax] = 7.994 s.
Amount = 6 Mean = 7.854 s. - 90.11%
OnTesterDeinit
------
Interval = 52.296 s., Count = 0, 0.0 unit/sec


Result on MetaQuotes-Demo

OnTesterInit
i = 0 Pass = 0 OnTester = 1.497 s.: Count = 2456073, 1640663.3 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 1 Pass = 1 OnTester = 1.494 s.: Count = 2456073, 1643957.8 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 2 Pass = 2 OnTester = 1.496 s.: Count = 2456073, 1641760.0 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 3 Pass = 3 OnTester = 1.493 s.: Count = 2456073, 1645058.9 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 4 Pass = 4 OnTester = 1.499 s.: Count = 2456073, 1638474.3 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
i = 5 Pass = 5 OnTester = 1.498 s.: Count = 2456073, 1639568.1 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1653
iMin = 3 Results[iMin] = 1.493 s.
iMax = 4 Results[iMax] = 1.499 s.
Amount = 6 Mean = 1.496 s. - 49.11%
OnTesterDeinit
------
Interval = 18.279 s., Count = 0, 0.0 unit/sec


Total amount of ticks on aFIBOGroup-MT5 Server is 15925124 and tester performance is 2038807.3 units/sec.MetaQuotes-Demo has 2456073 ticks and tester performance 1645058.9 unit/sec. That is, on the second server, the tester's performance has dropped by 20%. But the tester should not depend on the trade server!

Reproducible without any problems.

 
Alexey Kozitsyn:
It didn't help:) OK, no need to guess, we just need an answer from the SD. Such crutches should not be acceptable anyway!

Strange. I've been poking for about 10 minutes before posting and so I periodically keep-poking by switching the chart period and changing true to false in the indicator parameter. I don't see a problem. Of course it's crutches, that's why I said it was a temporary solution.

 
Alexey Kozitsyn:
Didn't work:) Ok, why guess, we need to get an answer from the SD. Such crutches shouldn't be acceptable anyway!

It works without any problems. Of course it makes sense to define the output buffers first, and then the colour buffer, which is what's done now.

 
Vitaly Muzichenko:

It works without any problems. Of course, it makes sense to define the output buffers first and then the colour buffer, which is what is done now.


Vitaly, please get to the bottom of the problem first. When the setting is on, everything works fine. The problem starts when the setting is disabled.
 
Alexey Viktorov:
Your version is more stable, and even almost always works correctly (if you don't switch the TF). But if you switch it and then switch it back... It's a mess again.
 
fxsaber:
(string)NormalizeDouble(0.99872, 5) - very long result.

No error, some numbers in decimal notation cannot be exactly represented in double

The following code gives a normal result
DoubleToString(0.99872, 5)

 
Evgeny Chernyshev:

No error, some numbers in decimal notation cannot be exactly represented in double

The following code gives you a normal result
DoubleToString(0.99872, 5)

Got it, thanks!

 
Alexey Kozitsyn:
Vitaly, get to the bottom of the problem first, please. When the setting is on, everything works fine. The problem starts when the setting is switched off.

Alexey, I apologise, I missed another correction

   //if(inpUseArrows) // Если отображать нужно
   //  {
      SetPlotParametersArrow(0,0,bufArrowUp,false,"test up",EMPTY,clrLime,233,10);
      SetPlotParametersArrow(1,1,bufArrowDn,false,"test dn",EMPTY,clrRed,234,-10);
   //  }

Corrected in that post too, marked in red.

 
Alexey Viktorov:

Alexei, I'm sorry, I missed another correction.

Corrected in that post, too, with the marking in red.

That's the whole point! It turns out you just turned it off and all the arrays under all the graph series are used. But the point is precisely to give the user the ability to disable some of the graph series if necessary. And if necessary - turn it on!

 
Alexey Kozitsyn:

That's what it's all about! So, you just turn it off and all arrays for all graph series are used. But the point is precisely to give the user the option to disable part of the graph series if necessary. And if necessary - switch it on!

Well, the number of graph series is defined at the beginning of the code, which doesn't change when you switch the TF.

I am afraid that it is invincible in mql5.

However, there is one more trick that can be used to exclude the display of graphical series in the data window

PlotIndexSetString(plotIndex, PLOT_LABEL, NULL);

It works in mql4. I have to check how it works in mql5, I haven't tested it yet.

No... it does not work in mql5. It works in mql5.

      PlotIndexSetInteger(0, PLOT_SHOW_DATA, true);
      PlotIndexSetInteger(1, PLOT_SHOW_DATA, true);
   if(!inpUseArrows) // Если отображать не нужно
     {
      PlotIndexSetInteger(0, PLOT_SHOW_DATA, false);
      PlotIndexSetInteger(1, PLOT_SHOW_DATA, false);
     }
Reason: