Errors, bugs, questions - page 2381

 

NormalPrice error! Good afternoon to all. I modified c mql4 to mql5 and now I got NormalPrice error. Please help me to understand the reason.

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\OrderInfo.mqh>

CPositionInfo  o_position;    //класс для управления открытыми позициями
CTrade         o_trade;     
CSymbolInfo    o_symbol;
COrderInfo     o_order;
//+------------------------------------------------------------------+
//| Переменные вводимые при запуске параметры                        |
//+------------------------------------------------------------------+
input double  StartLot    = 0.1;
input int     Indent      = 30;
input int     Step        = 10;
input double  ProfitClose = 20;
input int     MagicNumber = 12345;
input int     Slippage    = 30;
//+------------------------------------------------------------------+
//| Изменяемые параметры в программе                                 |
//+------------------------------------------------------------------+
int dStep;
int dIndent;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   dStep = Step;
   dIndent = Indent;
   
   if (!o_symbol.Name(Symbol()))
      return(INIT_FAILED);
   
   RefreshRates();
   
   o_trade.SetExpertMagicNumber(MagicNumber);
   //Проверка режимов открытия ордеров через функцию
   if (IsFillingTypeAllowed (o_symbol.Name(), SYMBOL_FILLING_FOK))
   {
      o_trade.SetTypeFilling(ORDER_FILLING_FOK);
   }
   else if (IsFillingTypeAllowed (o_symbol.Name(), SYMBOL_FILLING_IOC))
   {
      o_trade.SetTypeFilling(ORDER_FILLING_IOC);
   }
   else 
   {
      o_trade.SetTypeFilling(ORDER_FILLING_RETURN);
   }

   o_trade.SetDeviationInPoints(Slippage);
   
   if (o_symbol.Digits() == 3 || o_symbol.Digits() == 5)
   {
      dStep    *= 10;
      dIndent  *= 10;
   }

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   datetime             lpos_time         = 0;
   double               lpos_price_open   = 0.0;
   double               lpos_volume       = 0.0;
   ENUM_POSITION_TYPE   lpos_type         = -1;
   int                  pos_count         = 0;
   double               sum_profit        = 0;
   //счечик открытых позиций
   for (int i = PositionsTotal() - 1; i>=0; i--)
   {
      if (o_position.SelectByIndex(i))
      {
         if (o_position.Symbol() == o_symbol.Name() && o_position.Magic() == MagicNumber)
         {
            if (o_position.Time() > lpos_time)//если время позиции больше чем время последней позиции
            {
               lpos_time         = o_position.Time();
               lpos_price_open   = o_position.PriceOpen();
               lpos_volume       = o_position.Volume();
               lpos_type         = o_position.PositionType();
            }
            pos_count++;
            sum_profit = sum_profit + o_position.Commission() + o_position.Swap() + o_position.Profit();
         }
      }
   
   }
   //счетчик количества отложенных ордеров
   int stop_count = 0;
   for (int i = OrdersTotal()-1; i>=0; i--) //OrderTotal считает только отложенные ордера
   {
      if (o_order.SelectByIndex(i))
      {
         if (o_order.Symbol() == o_symbol.Name() && o_order.Magic() == MagicNumber)
         stop_count++;
      }
   
   }
//Функция проверки котировок
   if (!RefreshRates())
      return;
   //
   if (sum_profit > ProfitClose)
   {
      CloseAll();
      return;
   }
   //
   if (pos_count>0)
   {
      if (lpos_type == POSITION_TYPE_BUY && o_symbol.Bid() < lpos_price_open - dStep * o_symbol.Point())
      {
         o_trade.Sell(lpos_volume * 2, o_symbol.Name());
      }   
      if (lpos_type == POSITION_TYPE_SELL && o_symbol.Ask() < lpos_price_open + dStep * o_symbol.Point())
      {
         o_trade.Buy(lpos_volume * 2, o_symbol.Name());
      }   
      o_trade.SellStop(StartLot, o_symbol.Bid() - dIndent * o_symbol.Point());
      o_trade.BuyStop(StartLot, o_symbol.Ask() + dIndent * o_symbol.Point());
      return;
   }
   if (pos_count > 0 && stop_count > 0)
      DeleteStopOrders(); 
}
//Функция проверки котировок
bool RefreshRates()
{
   if (!o_symbol.RefreshRates())
      return (false);
   if (o_symbol.Ask() == 0 || o_symbol.Bid() == 0)
      return (false);
   return(true);
}   

//+------------------------------------------------------------------+
bool IsFillingTypeAllowed (string symbol, int fill_type)
{
   int filling = (int) SymbolInfoInteger(symbol, SYMBOL_FILLING_MODE);//запрашиваем режим открытия
   return(filling && fill_type);
}   
//+------------------------------------------------------------------+
void  CloseAll()
{
   for (int index = PositionsTotal()-1; index >=0; index--)
   {
      if (o_position.SelectByIndex(index))
      {
         if (o_position.Symbol() == o_symbol.Name() && o_position.Magic() == MagicNumber)
         {
            o_trade.PositionClose(o_position.Ticket());
         }
      }
   }
}
//+Функция удаления стоп ордеров
void  DeleteStopOrders()
{
   for (int i = OrdersTotal()-1; i>-0; i--)
   {
      if (o_order.SelectByIndex(i))
         if (o_order.Symbol() == o_symbol.Name() && o_order.Magic() == MagicNumber)
            o_trade.OrderDelete(o_order.Ticket());
   }
}

 
The question may be off-topic, but I don't see the point in just creating one. I'll ask it here.
What does signal reliability depend on?
 
Evgeniy Kazeikin:
The question may be off-topic, but I don't see the point in just creating one. I'll ask it here.
What is the reliability of the signal based on?
There are five or six components, calculated using a complex formula, then a scale is drawn with the appropriate colour
 
Slava:

In addition to the above errors in the tester (I am testing a multicurrency EA), the tester does not want to display other symbols, and the log contains numerous errors of no synchronization, also under the number 4001.

Again, in the 1981 build, everything worked without errors. In 1983 it's trouble.

Synchronization check feature:

//+------------------------------------------------------------------+
//| Проверка синхронизации данных                                                                                               |
//+------------------------------------------------------------------+
bool CheckSync(const string &usingSymbols[],// Список используемых символов
               const ENUM_TIMEFRAMES timeframe          // Рабочий ТФ
               )
  {
//--- Цикл по символам
   for(int i=0; i<_symbolsSize; i++)
     {
      //--- Проверяем синхронизацию i-го символа
      if(!SymbolIsSynchronized(usingSymbols[i]) || // Если нет синх. данных терминала и сервера или..
         !SeriesInfoInteger(usingSymbols[i],timeframe,SERIES_SYNCHRONIZED))   // ..не синх. данные по символу/периоду на данный момент
        {
         //---
         Print(__FUNCTION__,": ВНИМАНИЕ! Синхронизация по '"+usingSymbols[i]+"' ТФ "+EnumToString(timeframe)+" отсутствует!");
         Print(__FUNCTION__,": error = ",GetLastError());
         //--- Возвращаем ложь
         return( false );
        }
     }
//--- Все символы синхронизованы
   return( true );
  }

Synchronisation is supported by a minute-by-minute request for data on each character with CopyTime(). ResetLastError() does not reset error number 4001 before calling the synchronization check functions.

 

Hello, after the MT5 update on 8 November the horizontal lines are no longer drawn by this script in the strategy tester. And the comment is not displayed.

Please advise how to fix it.

Error 4001.

2019.02.11 20:42:53.522 Terminal        MetaTrader x64 build 1983 started (MetaQuotes Software Corp.)
2019.02.11 20:42:53.528 Terminal        Windows 10 (build 14393) x64, IE 11, UAC, Intel Core i3  M 330 @ 2.13 GHz, Memory: 1797 / 3885 Mb, Disk: 359 / 368 Gb, GMT+8
 
San Kos:

Hello, after the MT5 update on 8 November the horizontal lines are no longer drawn by this script in the strategy tester. Please advise how to fix it.

Error 4001.

Confirmed.

Terminal and system:

2019.02.10 16:53:22.710 MetaTrader 5 x64 build 1983 started (MetaQuotes Software Corp.)
2019.02.10 16:53:23.196 Windows 10 (build 17134) x64, IE 11, UAC, Intel Core i3-3120 M  @ 2.50 GHz, Memory: 3340 / 8077 Mb, Disk: 101 / 415 Gb, GMT+2
2019.02.10 16:53:23.196 C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075


Example: Expert AdvisorDaily range works withOBJ_HLINE. In tester errors:

2019.02.11 14:37:47.737   InpStartMinute=5
2019.02.11 14:37:47.795 2018.09.01 00:00:00   VLineCreate: failed to create a vertical line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   VLineMove: failed to move the vertical line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   VLineCreate: failed to create a vertical line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   VLineMove: failed to move the vertical line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   HLineCreate: failed to create a horizontal line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   HLineMove: failed to move the horizontal line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   HLineCreate: failed to create a horizontal line! Error code = 4001
2019.02.11 14:37:47.795 2018.09.01 00:00:00   HLineMove: failed to move the horizontal line! Error code = 4001
2019.02.11 14:37:48.969 USDJPY,Daily: history cache allocated for 548 bars and contains 433 bars from 2017.01.02 00:00 to 2018.08.31 00:00
 
Alexey Kozitsyn:

In addition to the above errors in the tester (I am testing a multicurrency EA), the tester does not want to display other symbols, and the log contains numerous errors of no synchronization, also under the number 4001.

Again, in the 1981 build, everything worked without errors. In 1983 it's trouble.

Synchronization check feature:

Synchronisation is supported by a minute-by-minute data request for each character with CopyTime(). ResetLastError() does not reset error number 4001 before calling the synchronization check functions.

This error has already been fixed.

 
Vladimir Karputov:

Confirmed.

The terminal and the system:


Example:Daily range adviser works withOBJ_HLINE objects. In the tester errors:

To be fixed in the next build.

 

Bild 1984 MQ Demo Server


 

I wonder if anyone else has this problem on the 1983 build? The multi-currency tester refuses to make coffee, seems to have turned into a single-currency tester. I'm trying to get bars for different symbols, but no matter which one I request, it returns the one that is set in the tester settings.


Here is a simple Expert Advisor that blocks an error.

int OnInit()
  {
      EventSetMillisecondTimer(200);
      return INIT_SUCCEEDED;
  }

void OnTimer()
{
      MqlRates aBarsCHFJPY[], aBarsEURUSD[], aBarsUSDCHF[];
      int countBars = CopyRates("CHFJPY", PERIOD_H1, 1, 1, aBarsCHFJPY)
         , countBars2 = CopyRates("EURUSD", PERIOD_H1, 1, 1, aBarsEURUSD)
         , countBars3 = CopyRates("USDCHF", PERIOD_H1, 1, 1, aBarsUSDCHF);
      
      ExpertRemove();
      return;
}

I look at aBarsCHFJPY[0], aBarsEURUSD[0], aBarsUSDCHF[0] with debugging, and see that they are absolutely equal (and which one exactly depends on selecting a symbol in tester settings). Changing the tester date has no effect on anything. That said, the character properties seem to be correct. Rolled back to build 1966 - everything is ok there.

Reason: