MQL5 bug when working with iClose/iOpen timeseries access, etc. - page 5

 
Renat Fatkhullin:

Please show me the reference code of indicator, which always keeps the latest 2000 ticks of each symbol from Market Watch.

Otherwise you get guessing on one side and only recommendations in the form of words on the other side.

 
Renat Fatkhullin:

I have to look at the code.

The code above clearly has a bunch of logical and resource problems.

I'm doing something like this, please advise how and what to tweak if necessary:

bool flag = true;

//+————————————————————————————————————————————————————————————————————————————+
int OnInit ()
{
  /*
  тут определены и настроены буферы
  */
  

  flag = true;

  //---
  return (INIT_SUCCEEDED);
}
//+————————————————————————————————————————————————————————————————————————————+

//+————————————————————————————————————————————————————————————————————————————+
void OnDeinit (const int reason)
{
  //--- destroy timer
  EventKillTimer ();
}
//+————————————————————————————————————————————————————————————————————————————+

//+————————————————————————————————————————————————————————————————————————————+
int OnCalculate (const int       rates_total,
                 const int       prev_calculated,
                 const datetime &time        [],
                 const double   &open        [],
                 const double   &high        [],
                 const double   &low         [],
                 const double   &close       [],
                 const long     &tick_volume [],
                 const long     &volume      [],
                 const int      &spread      [])
{
  //Print ("---");
  //Print (rates_total, " ", prev_calculated);
  //Print ("---");

  if (flag)
  {
    if (SeriesInfoInteger (Symbol (), Period (), SERIES_SYNCHRONIZED))
    {
      Print ("1 История синхронизирована");
      int bars = Bars (Symbol (), Period ());
      Print ("Баров в истории ", bars);


      MqlTick ticks_array [];

      datetime from = TimeByNumberOfCandles (Symbol (), PERIOD_M1, ParentCandles_P);
      MqlDateTime sdt;
      ulong from_msc = ((ulong)from) * 1000;

      ResetLastError ();
      int count = CopyTicksRange (Symbol (), ticks_array, COPY_TICKS_INFO, from_msc); //, to_msc);
      Print ("Скопировано ", count, " тиков");

      int error = GetLastError ();
      Print (error);

      if (count <= 0 || error != 0)
      {
        Print ("Ошибка при получении данных");
        return (rates_total);
      }

      Print (ticks_array [0].time_msc, " ", ticks_array [count - 1].time_msc); // 0-й самый старый

      for (int i = 0; i < count; i++)
      {
        // тут вычисления и операции с тиками
      }

      /*
      тут заполнение индикаторных буферов значениями полученными после работы с тиками
      */
      }
      
      flag = false;
    }
    else
    {
      Print ("2 История НЕ синхронизирована!");
      return (rates_total);
    }
  }


  return (rates_total);
}
//+————————————————————————————————————————————————————————————————————————————+
 
Renat Fatkhullin:

I have to look at the code.

The code above clearly has a bunch of logical and resource problems.

Is there a logical problem in this code, or am I missing something?

Forum on trading, automated trading systems and strategy testing

MQL5 Bug in iClose/iOpen time series access, etc.

Stanislav Dray, 2018.11.14 16:28

Your attitude to bug reports is strange. It's not like I'm paid to prove anything. I've laid out the situation as best I could.

I'm not the only one with the problem, the problem appeared after your 30th update, but still you insinuate that I am a fool and blame some retarded indicators.

Weren't they slow for a year before that?

Here is an example of code which hangs 25 minutes after start on M30:

//+------------------------------------------------------------------+
//|                                                      Feezzzz.mq5 |
//|                                   Copyright 2018, Dray Stanislav |
//|                               https://www.mql5.com/ru/users/fan9 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, Dray Stanislav"
#property link      "https://www.mql5.com/ru/users/fan9"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
    datetime CM1_T[1];
    if(CopyTime(_Symbol,PERIOD_M1,0,1,CM1_T)==-1){
      Comment("\n\n CopyTime return -1");
      return;
    }
    Comment("\n\n CopyTime : "+TimeToString(CM1_T[0],TIME_DATE | TIME_SECONDS));   
  }
//+------------------------------------------------------------------+
//| Trade function                                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
//---
   
  }
//+------------------------------------------------------------------+

 
Renat Fatkhullin:

You should write the indicator with a clear understanding that you will not get everything at once.

In OnInit you must stimulate the loading of history of needed instruments by single calls of CopyXXX, but you have to wait for the full initialization in OnCalculate.

Your initialization phase seems to have an error - you are waiting for data incorrectly and blocking.

I will try to do so,

Now I make requests to OnCalculate and wait there (not every tick of course, but only the first time of calculation).

 
fxsaber:

Please show me the reference code of indicator, which always keeps the latest 2000 ticks of each symbol from Market Watch.

I am not sure how to use it, but I am sure I have the right to use it.

I agree! It is better not even for ticks, but for bars.

You need an example of an Approved True Multicurrency Code.

Otherwise we will remain in the dark...

 

I will try to localise the error and report back as I find it

 
transcendreamer:

I agree! Better not even ticks but bars.

We need an example of an Approved True Multicurrency Code.

Otherwise we'll still be in the dark...

Bars and ticks are different epistasis living in MT5 independently.
 
Vladimir Karputov:

It has also always been recommended that if you are working with someone else's timeframe - you should get OHLC from that timeframe once a minute (any CopyXXXX function). This has always been the case.

I already wanted to spit on everything that's going on here, but unfortunately I've spent about 10 years on the MQ product.

Now it's all business. Vladimir your advice about using CopyXXXX functions was used by me, because it was not any difficulty from the point of view of my non-professionally written code.

Honestly I wanted the problem to be only in my crooked hands, but no the problem is not only in them. I have a screenshot below, anticipating strange explanations from technical support saying that I have coded incorrectly and 100500 other indicators, so what do you want, there will be problems. I don't have 100500 other indicators, there is no expert, I have only two tools open in the terminal, the indicator test is running on EURUSD 1M, the indicator calls the data from M15 timeframe of the same tool, I'm not trying to load other symbols data, there are only few of them in the market review.

It's an ideal situation for the terminal in terms of loading, which of course will not be the case in working conditions, but even in this case there is a problem and in my opinion this problem is called "BAG".

In the indicator the iClose and iBars functions are called only to reflect the state in Commet(). In the market review at the time of the screenshot creation, the current state of iClose and iBars functions call is in the terminal window, further the calculation part of the indicator uses CopyXXXX function.

BAG

As you can see the indicator was reloaded at 16:31 and worked successfully (I was even getting happy), but iClose data update stopped after 00:15, respectively the CopyXXXX function also returns no updated data, i.e. the error occurs somewhere in the depths of MT.

In my opinion, there is a failure when reading data from the server, the reasons may be mass (no internet, the server was busy, etc.), but why the resumption of work after eliminating the causes of communication does not happen, so I conclude that you can test the users source code as much as you want, but if you have a server next door, this problem you will never identify, and it exists and it does not occur only because of the bad hand coder.

 

Also decided to test the code from Stanislav yesterday. After a few hours the time update stopped. I didn't switch timeframes, I just updated it via context menu of the chart and the time went on.

Today I modified the code a little bit to see the time and the current timeframe.

void OnTick()
{
 datetime CM1_T[1];
 datetime CM2_T[1];
 CopyTime(_Symbol,PERIOD_M1,0,1,CM1_T);
 CopyTime(_Symbol,PERIOD_CURRENT,0,1,CM2_T);
 Comment("CopyTime PERIOD_CURRENT: "+TimeToString(CM2_T[0],TIME_DATE | TIME_SECONDS)+"\nCopyTime PERIOD_M1: "+TimeToString(CM1_T[0],TIME_DATE | TIME_SECONDS));   
}

In 15 minutes it stopped updating in "not native" timeframe, but with current timeframe it was updating normally. After refreshing graph the time has started again.

The terminal is running in portable mode. The system and the terminal itself are located on an SSD disk.


 

I don't know what happened, but when I wrote the bot for the latest MQ Championship in MQL5, it was multicurrency and I didn't notice any problems with loading data from other instruments.

It may have consumed a lot of resources, but it gave the expected result, and not a roulette game like now.

This problem, for example as a developer of commercial products for MQL5, will not characterize me in a very good way and it will be doubly unpleasant if a person pays for a product purchased from the Market and it just looks glitchy because of such "BOGS".