Errors, bugs, questions - page 382

 
aharata:

Ticks in the file: 1159105, and tick volume for this period: 1161872

What could this be about? How do I get the tester's ticks right?

1 161 872 - 1 159 105 = 2 767 ticks, which is 0.2% of 1 161 72 ticks.

An error of 0.2% in ticks modelling is acceptable and normal, because it does not make sense in some situations(bar configurations) to generate additional ticks. The tester always generates a little less ticks (at the level of 0.2% shown) than it was in reality.

If the green quality bar of the raw data is close to 100%, you can use the generated tick sequence of the tester without fear.

Алгоритм генерации тиков в тестере стратегий терминала MetaTrader 5
Алгоритм генерации тиков в тестере стратегий терминала MetaTrader 5
  • 2010.05.21
  • MetaQuotes Software Corp.
  • www.mql5.com
MetaTrader 5 позволяет во встроенном тестере стратегий моделировать автоматическую торговлю с помощью экспертов на языке MQL5. Такое моделирование называется тестированием экспертов, и может проводиться с использованием многопоточной оптимизации и одновременно по множеству инструментов. Для проведения тщательного тестирования требуется генерировать тики на основе имеющейся минутной истории. В статье дается подробное описание алгоритма, по которому генерируются тики для исторического тестирования в клиентском терминале MetaTrader 5.
 
Thanks, for the prompt reply. The quality of history is 100% (great indicator in the tester, by the way). When I trade virtually, I use indicators, and now I am worried about synchronization of ticks and indicators data (I don't care if 2 tenths does not harm me)... Thank you.
 
Is there any way to get a date value for a bar in the future? I need to build a grid in advance after a certain number of bars.
 
vdv2001:
Is there any way to get the date value for a bar that is in the future? I need to build a grid in front after a certain number of bars.

If only time, then: take the base bar; find out its time; get the number of seconds in a period (TF); multiply the seconds by the number of bars and add to the date of the base bar.

 
Interesting:

If only time, then: take the base bar; find out its time; get the number of seconds in a period (TF); multiply the seconds by the number of bars and add to the date of the base bar.

It is not certain that the bar will remain at the same index (taking into account the shift), but in general, yes, we can count the right number of bars forward and set the object and it will be exactly where we want it. It is more complicated with the past, it is caused by skipping bars. So objects that have gone from zero to the first point will probably need to be checked for correctness.

The main thing here is to find out what is more important - bar regularity or time regularity?

Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
  • www.mql5.com
Доступ к таймсериям и индикаторам / Bars - Документация по MQL5
 
Interesting:

If only time, then: take the base bar; find out its time; get the number of seconds in a period (TF); multiply seconds by the number of bars and add to the date of base bar.

I'm doing it now, I thought it could be simpler, like BarToTime() function.)

Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
  • www.mql5.com
Доступ к таймсериям и индикаторам / Bars - Документация по MQL5
 
Urain:

It is not certain that the bar will remain at the same index (taking into account the shift), but in general, yes, you can count the right number of bars forward and set the object and it will be exactly where you want it to be. It is more complicated with the past, it is caused by skipping bars. Objects that have gone from zero point to the first one probably should be checked for correctness.

The main thing here is to find out if bar regularity or time regularity is more important.

The important thing is bar regularity, otherwise the corners appear crooked :((

I'm trying to build a GaN square.

 
vdv2001:

Bar regularity is important, otherwise the angles get crooked :((

Trying to build a gan square.

Think of it as adding seconds, but on each new bar just redraw the picture (you can even write a function of necessity) and that's it....

Обработчик события "новый бар"
Обработчик события "новый бар"
  • 2010.10.04
  • Konstantin Gruzdev
  • www.mql5.com
Язык программирования MQL5 позволяет решать задачи на совершенно новом уровне. Даже те задачи, которые уже вроде имеют решения, благодаря объектно-ориентированному программированию могут подняться на качественно новый уровень. В данной статье специально взят простой пример проверки появления нового бара на графике, который был преобразован в достаточно мощный и универсальный инструмент. Какой? Читайте в статье.
 
vdv2001:

Bar regularity is important, otherwise the angles get crooked :((

Trying to build a gan square.

Does it matter to you that the bars are skipped?
 
Urain:
And you do not care that the bars go with gaps?

No Gan only counted the working bars!!!

The missing periods are what I needed to remove.

Thanks to everyone for the tips I did, through forming a time array.

Maybe someone will need it:

//   int bars - количество расчетных баров
//   datetime time1 - время нулевого бара

   datetime iTime[];
   int rates_time;
   rates_time=CopyTime(NULL,m_period,time1,TimeCurrent(),iTime);
   if(rates_time==-1) return(false);
   ArrayResize(iTime,bars+1);
   if(rates_time<=bars)
     {
      int shift=rates_time-1;
      for(int i=1;i<=ArraySize(iTime)-rates_time;i++)
        {
         iTime[shift+i]=iTime[shift]+PeriodSeconds(m_period)*i;
        }
     }
   datetime shifttime=time1-iTime[0]; // смещение времени для корекции массива
   for(int i=0;i<=bars;i++) iTime[i]=iTime[i]+shifttime; // корректируем массив
   time2=iTime[bars];

True you need to recalculate when a new bar appears.

Reason: