Questions from a "dummy" - page 251

 
Silent:
It's all clear, I've already got every step printed, and I've got the function in a separate script... Ok, I'll think about it at my leisure.

No, it's not clear to you. It depends on what is printed. )) You are already being pointed out in three voices to the parameters being transmitted.

Forum on trading, automated trading systems and strategy testing

Questions from Dummies

tol64, 2013.05.24 13:02

Check (print to log) start time (t[0]+b) and end time (t[0]) of the range. You'll get the hang of it straight away.

 
stringo:

There is no need to abandon the function.

When you query for data in the range"current time - current time plus a number of seconds", it means that you are asking for data from the future. The data does not yet exist at the time of the request.

If you were requesting data in the range "current time - current time minus some number of seconds", then you are requesting potentially existing data.

What future are we talking about, where did you see that?

All queries go only to the past.

In the test script, the bar is explicitly set from which to count...

Generally, the extremes of the zigzag are specified, which does not give the exact time...

 
Silent:

What future are we talking about, where did you see that?

OK. Current time 2013.05.24 15:43:29

Add 600 seconds to the current time. We get 2013.05.24 15:53:29.

Then we query for the calculated range. But we have data only up to and including the current time. Between 2013.05.24 15:43:29 and 2013.05.24 15:53:29 there is no data yet.

But if you spin the ten-minute cycle, the data may well appear. Except that 2013.05.24 15:43:29 becomes the past time and 2013.05.24 15:53:29 becomes the current time.

Документация по MQL5: Дата и время / TimeCurrent
Документация по MQL5: Дата и время / TimeCurrent
  • www.mql5.com
Дата и время / TimeCurrent - Документация по MQL5
 
tol64:

No, it's not clear to you. It depends on what is printed. )) You are already being pointed out in three voices to the parameters being transmitted.

https://www.mql5.com/ru/forum/3775/page252#comment_507621

There's like.

   Print(tm[0]);
 
stringo:

Ok. Current time 2013.05.24 15:43:29

Add 600 seconds to current time. We get 2013.05.24 15:53:29

We then query for the calculated range. But we have data only up to and including the current time. Between 2013.05.24 15:43:29 and 2013.05.24 15:53:29 we still have no data.

But if you spin the ten minute cycle, the data might well show up. Except that 2013.05.24 15:43:29 becomes the past time and 2013.05.24 15:53:29 becomes the current time.

//--- переменные для указания параметров функции
   int start = 5; // индекс бара
   int count = 1; // количество баров
   int b=72000;   
   int bm;        // надо получить
   datetime tm[]; // массив, в котором возвращается время баров
//--- копирование времени 
   CopyTime(_Symbol,PERIOD_CURRENT,start,count,tm);
//--- вывод результата
   Print(tm[0]);

   bm=Bars(_Symbol,PERIOD_M1,tm[0]+b,tm[0]);
   Print("bm = "+bm);
//--- возвращает bm = 1201
   bm=Bars(_Symbol,PERIOD_M1,tm[0]-b,tm[0]);
   Print("bm = "+bm);

Where is

int start = 5; // индекс бара

bar whose time I'm getting.

I do NOT use current time. At all.

 
I'll put in a separate check for the future, then we'll see.
 
Silent:

Where

is the bar whose time I get.

I do NOT use the current time. At all.

That is, in tm[0] you have the time of the 5th bar from the end.

In that case, in the first request for data other than the current timeframe (you are requesting minutes), you could easily get 0 bars, because that data is not yet in the terminal.

Just for that, we once published a script on guaranteed uploading of historical data of any existing symbol-period.

 
stringo:

We once published a script on this subject, which guarantees the uploading of historical data of any existing symbol-period.

Read the help section on organising data access

 
stringo:

That is, in tm[0] you have the time of the 5th bar from the end.

In this case, in the first request for data other than the current timeframe (you are requesting minutes), you can easily get 0 bars, because this data is not yet in the terminal.

We once published a script on the subject of guaranteed uploading of historical data of any existing symbol-period.

You can periodically get 0 even on the current timeframe, just on different bars. Very rarely, though. I can't reproduce it today, while yesterday I was getting it on almost every new (not called) bar.

I'll look for the script, thanks.

 

In general, the biggest confusion is why all Copy functions work, in the same conditions, - and I catch something left on the leopard?

It's fantastic...

Upd the possible answer to getting 0 on first run

Мы не можем прямо обратиться к серверу, но любая Copy-функция
при нехватке истории в формате HCC в терминал автоматически инициирует посылку
такого запроса от терминала к торговому серверу.

and Bars doesn't do that.

Upd 2 there's a letter missing in the help, in, highlighted in red.

Reason: