Questions from Beginners MQL5 MT5 MetaTrader 5 - page 531

 
Aleksey Lebedev:

It's a bit of a mess, isn't it?

I don't agree, because the person is making an indicator, and in an indicator you have to work with arrays from OnCalculate().
 
-Aleks-:

...

Pardon my impertinence, but can you show me how to combine your code and mine?

An ancient folk wisdom says: if you want to help a hungry man, don't give him a fish, give him a fishing rod.

If you have any questions, do ask.

 
Karputov Vladimir:
I don't agree, because the man makes an indicator, and in an indicator you need to work with arrays from OnCalculate().
time[0] if needed, and religion does not allow to use TimeCurrent().
 
Aleksey Lebedev:

It's a bit of a mess, isn't it?

And how do you know what day is on the 163 bar of the current TF?
 
-Aleks-:
And how do you know what day the 163 bar of the current TF is?
time[163]
So in the indicator you will get the opening date of the bar with index 163.
 
-Aleks-:
And how do I know what day is on the 163 bar of the current TF?

I don't quite understand the question.

int DayN=(time[0]-time[163])/86400;

0 = today's

1 = yesterday, etc.


Print(time[163]) or Comment(time[163]) will print the date/time in human form.


corrected.

 
Karputov Vladimir:
This way in the indicator you will get the open date of the bar with index 163.

Did an experiment, put 163 and got a line

2016.03.07 18:46:29.062 Start_day GBPUSD,H1: Start day 2016.02.25 03:00:00

And actually should have gotten the date 2016.03.01 00:00:00 !

I guess I'm not very good at explaining what I want to get, let me try again.

I need to make a calculation on each chart of the current TF. The calculation requires to know the date of the upper TF (days). Above I have attached the code - the idea is to know on each bar the maximum price of the upper TF at the time of the bar opening in the current TF.

 
Aleksey Lebedev:

I don't quite understand the question.

0 = today's

1 = yesterday, etc.


Print(time[163]) or Comment(time[163]) will print the date/time in human form.


corrected.

We will get the seconds we need to round up - rounding is the problem.
 
 
Alexey Kozitsyn:
Use TimeToStruct().

I can't figure out how to use it.

The second value requires"MqlDateTime&dt_struct// structure for taking values", but I don't understand how to use this MqlDateTime.