Questions from Beginners MQL5 MT5 MetaTrader 5 - page 535
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So, you need to specify such a request right away :) .
The situation is as follows: if there is a bar in the chart, it corresponds to a cell in the indicator buffer. As long as you don't write something into this cell, it will store rubbish.
When you divide integers (int,long,datetime etc.) the result is an integer, i.e. the remainder is discarded. 00:00 today and 23:59:59 yesterday, the difference will be 1 day.
Firstly it is not - it is proven experimentally in the indicator.
Secondly, how do you get a 1 - show me mathematically, given that we are originally calculating in seconds.
Exactly the same way as zeroing simple types. By assigning them a value of 0. Once the required fields have been assigned a value of 0 - use the reverse operation StructToTime().
Zeroed out:
MqlDateTime str1;
datetime Open_timePos=iTime(_Symbol,0,pos);
TimeToStruct(Open_timePos,str1);
str1.hour=0;
str1.min=0;
str1.sec=0;
datetime start_time=StructToTime(str1);
Print("день=",TimeToStr(start_time));
Aleksey Lebedev:
При делении целых чисел(int,long,datetime и т.п.) результат целое число, т.е. остаток отбрасывается. 00:00 сегодня и 23:59:59 вчера, разность будет равна 1дню.
-Aleks-:
First of all it's not - proven experimentally in the indicator.
Don't argue with the basics).
-Aleks-:
Secondly how do you get 1 - show me mathematically, given that initially we have the calculation in seconds.
Use conversion through structure, if it is easier to understand.
Don't challenge the basics)
Use structure conversion if it's easier to understand.
What is understood is what has been dealt with. I haven't tried your code to run it, but I think you did it yourself, so explain to me unintelligent how it works:
86401/86400-86400/86400 equals 1, if by rules of mathematics 1.000012-1=0.000012 , and int should round up to integer, i.e. 0.
What is understood is what has been dealt with. I have not tried your code to run, but I think you have done it yourself, so explain to me unintelligent how it works:
86401/86400/86400 equals 1, if according to the rules of mathematics 1.000012-1=0.000012 , and int should round to integer, i.e. 0.
but do it)
Start of the day 00:00:00 is divided by 86400 without a remainder, the previous one is at least 1 second less. Rounded off - the remainder of the division is discarded, not the whole expression.
86400/86400=1
86399/86400=0
and then run it)
The start of the day 00:00:00 is divided by 86400 without a remainder, the previous one being at least 1 second less. Rounded off - the remainder of the division is discarded, not the whole expression.
86400/86400=1
86399/86400=0
Guys! Is it possible to display the indicator on the chart programmatically? Or only by hand?