Questions from a "dummy" - page 68

 

x100intraday:

The main thing I want to know: is it possible to fill time buffers directly like price buffers (without resorting to CopyTime and other regular functions of copying into an array), and how, and if not, why?

2. Is it really necessary to create another pair of buffers for storing seconds since the beginning of 1970, but with type not datetime, but some double or long, for example, and at necessary moments to convert through TimeToString to time format as literal string?

1. impossible. with "why?" - to developers.

In your case, this is the simplest solution. (Guaranteed to work.) Since you raise the question about filling buffers similar to price ones.

If I were me, I would try to avoid such waste of memory at the algorithmic level, and in no case would I create buffers with useful data filled to 3%.

 
MetaDriver:

If I were me, I would try to avoid this waste of memory on an algorithmic level, and not create buffers with 3% usable data.

Well, here comes the question-explanation: https://www.mql5.com/ru/forum/1111/page529#comment_101059 with at least one intelligible and not incomprehensible answer, though quite the opposite. Interest is running high...
 
x100intraday:

yeah, bada))

"Date and timeconstants... " and "...may be represented as a literal string".

may or may not be represented... it's for input/output data in the usual date/time form.

In addition, we cannot associate arrays of this type with indicator buffers (and there's no need to?), we cannot apply SetIndexBuffer to arrays of this data type for well-known reasons.

there is nothing that prevents datetime type from being in the indicator buffer (it is desirable).

And we do not.

And in vain)

Compile the resulting code. We get the warning"truncation of constant value" with respect to strings with =EMPTY_VALUE(we are sadly surprised) and an error in the Expert report of the terminal: "Array out of range " with respect to the same strings (we get upset at last). It seems thatEMPTY_VALUE does not wantto fit into datetime type , while the array's size remains zero. ChangingEMPTY_VALUE to 0, the error disappears but the array still has zero size.

EMPTY_VALUE is of double type.

It would be easier with an indicator buffer - we don't need to determine the array size.

Another strange thing is that the size of ExtUpperBuffer and ExtLowerBuffer is non-zero, it means they fill, but fractals don't appear. Why should this be so?

eh, I don't know).

The main thing that interests me: is it possible to fill in the time buffers directly similar to price buffers (without resorting to the CopyTime and other regular functions of copying into the array), and how, and if not, why? Really, for this purpose I have to create another pair of buffers for storing seconds from the beginning of 1970, but with type not datetime, but some double or long, for example, and in necessary moments to convert through TimeToString to time format as literal string?

Access to data like datetime is similar to access to price data.

datetime is essentially the same int/long.

P.S.: who is too lazy to reproduce the Fractals.mq5 code, just tell me, how do you store the calculated specific time data (without calling handles of built-in indicators and working with them)?

it's the same as with integer data, int/datetime/long is the same.

 
Swan:

yeah, badaada))

nothing prevents datetime type from being in the indicator buffer (that's desirable).

And in vain)

It's easier with the indicator buffer - you don't need to determine the array size.

And what exactly am I doing wrong? Everything is described in detail, the source code is standard, time-tested, the simplest! Modifications are simple and obvious... I'm at a loss to speculate in my clouded mind... When I'm stuck on something, I might as well call a car mechanic with a crescent wrench...

And what's the runic spell to bind datetime arrays to indicator buffers? Again:


SetIndexBuffer

Binds the specified indicator buffer to a one-dimensional dynamic array of type double, declared globally.

 
x100intraday:

And what exactly am I doing wrong? After all, I've described everything in detail, the source code is generally standard, time-tested, the simplest! The modifications are simple and obvious... I'm lost in the speculation of my clouded mind... When I'm stuck on something, I might as well call a car mechanic with a crescent wrench...

And what's the runic spell to bind datetime arrays to indicator buffers? Again:


SetIndexBuffer

Binds the specified indicator buffer to a one-dimensional dynamic array of type double, declared globally.

You don't need this datetime. Write everything to a double array and convert it to datetime before using it (if needed).

Basically, the only difference between datetime and double is in presentation. You can losslessly convert time written in double to datetime.

Both are 8 byte types.

 
x100intraday:

And what exactly am I doing wrong? After all, I've described everything in detail, the source code is generally standard, time-tested, the simplest! The modifications are simple and obvious... I'm lost in the speculation of my clouded mind... When I get stuck on something, I want a car mechanic with a crescent wrench...

I can only guess at the details of the code with the changes...

And how to use runic spell to bind datetime type arrays to indicator buffers? Again:


SetIndexBuffer

Binds the specified indicator buffer to a one-dimensional dynamic array of type double, declared globally.

Urain has already answered it. Well, so that the compiler does not swear, something like this:

double ExtUpperTimeBuffer[];//обьявляем
...
ExtUpperTimeBuffer[xz0]=(double)time[xz1];//присваиваем
...
datetime XZ=(datetime)ExtUpperTimeBuffer[xz2];//юзаем
 

So... Yeah...

Nothing groundbreaking, but the ground is firmly planted, so to speak.

Thank you all for the medicinal kicking. I'll give it a try...

 
x100intraday:

Thank you all for the medicine kicks.

And kicks of good fortune : D
 

Is there an in-house analogue of the library function array.Add()?

P.S.: if not, give a year's supply of sleeping pills.

 
x100intraday:

Is there an in-house analogue of the library function array.Add()?

P.S.: if not, give a year's supply of sleeping pills.

Why not store date in indicator......or buffer...... type double

Lots of dots added, otherwise some kind of link appears.

double time[10];

time[0] = (double) D'3000.12.31 23:59';
time[1] = (double) D'2030.12.31 23:59';

Print(TimeToString((datetime)time[0]));
Print(TimeToString((datetime)time[1]));

Everything converts correctly with no errors

Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
  • www.mql5.com
Основы языка / Типы данных / Вещественные типы (double, float) - Документация по MQL5
Reason: