Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 767

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
Of course, the comparison is based on the number of seconds that have elapsed since the year 70, but this number of seconds takes into account everything - date and time.
I will just give you an example, which is essentially a simplification of a problem I recently encountered.
Initially I had such a solution:
And now the gimmick: the print specified in the code will pop up on Friday, but not after 21:30, but at 00:00 on the first tick.
Because when my broker's server got Friday, on my local PC it was still Thursday, timeshift is different.
In the tester, everything is OK and the print will be released as it should be on Friday after 21:30. Isn't that confusing?
Of course, the comparison is based on the number of seconds that have elapsed since the year 70, but this number of seconds takes into account everything - date and time.
I will just give you an example, which is essentially a simplification of a problem I recently encountered.
Initially I had such a solution:
And now the gimmick: the print specified in the code will pop up on Friday, but not after 21:30, but at 00:00 on the first tick.
Because when my broker's server got Friday, on my local PC it was still Thursday, timeshift is different.
In the tester, everything is OK and the print will be released as it should be on Friday after 21:30. Isn't that confusing?
Of course it's confusing. It's just confusion in your head. TimeToString("21:30") will give the current date from 21:30:00 to 21:29:59 the next day. I'll correct the comments in your code.
And this code will work correctly
There are two MT4 terminals on the same laptop: one with 4 decimal places and one with 5 decimal places. In the same time the traffic on the first one is 105/0 kb, on the second one 3450/0 kb. First one is CPU intensive by 6%, second one by 39%. What is the problem? Is this even a norm?
AlexeyVik
Changed the date on my computer to 2000.
ran this script:
and got this:
hence StringToTime() takes the date from the local computer
AlexeyVik
Changed the date on my computer to 2000.
ran this script:
and got this:
So StringToTime() takes the date from the local computer
So what? Let it take it from the moon, as long as you set "from and to" time passed XXX seconds and this integer number we compare with number of seconds passed from 01.01.1970 of the needed time.
You'd better check this line
where you had the problem. Today is Friday.
You'd better check that line
where you had the problem. Today is Friday.
I checked, if the local computer has a lower date than the broker's date, then the printers are there,
but if the local computer has a higher date than the broker's, no printers.
i.e. the time has passed, i.e. "11:30".
in the first case TimeCurrent() is compared to 2014.11.06 11:30, and in the second caseto 2014.11.0811:30
PS corrected the highlighted
The first line is clear, the comment on the second line is not.
Why is Friday far away when it has already come? After all, the second line is only executed if it is Friday.
I have checked, if the local computer has a lower date than the broker's date, then the printers are there,
and if the date on the local computer is higher than the broker's date, then there are no printers.
i.e. the time has passed, i.e. "11:30".
in the first case TimeCurrent() is compared to 2014.11.06 11:30, and in the second caseto 2014.11.0811:30
PS corrected the highlighted
Well here I have local time greater than server time by 1 hour.
This script
Outputs the following values.
First the number of seconds elapsed from 01.01.1970 to the specified time, and then the time in the form we are used to.
On this basis, please explain what confuses you about these values?
Yes. In my second comment I was thinking about something else.
да.
Hello.
There is a task like this. (can't attach it to a tick)
If a pending order triggers {then...}.
In my EA, I use Terminal.mqh to calculate orders.
Terminal // Mas_Tip[0] open Buy
// if the number of Buy ordershas increased by 1
if (Mas_Tip[0]+1)
{
function
}
Everything works. But it triggers on every next tick.
How to attach this case to a tick? And then compare the value on the previous tick and on the current tick.
Well, my local time is 1 hour longer than the server time.
So, can you explain what is confusing about these values?
There is nothing confusing about these values, everything is correct there, but that is not what we are talking about.
The problem with Friday in particular is not relevant if your local time is X hours longer than the broker's time.
But imagine if on your local computer there is not +1, but -1 hour difference with the broker.
And there is this simple condition:
In this case:
1. the broker will have the first tick of Friday, for example today's tick, which has a time of 2014.11.07 00:00
2. Take the number of seconds elapsed from01.01.1970 00:00 till the tick in question, i.e.2014.11.07 00:00
3. we take the number of seconds elapsed from 01.01. 1970 00:00 till06.11.2014 21:30 (it is yesterday's date, because we take the time of the local PC, which at the moment of the tick is not Friday, but Thursday, which is the 6th day, or to be more precise, 2014.11.06 23:00, the difference of 1 hour)
Voila, the number of seconds in point 2 is greater than in point 3.
This means that the first Friday tick will execute the print specified in the code, although if theStringToTime() function takes the date from the broker's server, then everything would work as planned, the print would pop up on Friday only after the time goes over21:30