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
No, take your time reading this topic
read this twice if one time is not enough
and do it again if reading twice is not enough
... the answer why not is in this topic !!
You mean he should be MathMod'ing for 24 right?
But I still want to know whats wrong with Hour(). I forgot :)
Documentation:
Note: At the testing, the last known server time is modelled.
When you launch terminal, Hour() stores the hour of the last_time a tick was received from the broker. This hour_value wouldn't change while the terminal is opened. Last_known_server_time may_not technically be the last time a tick was received however that's the easiest way I can think of explaining it.
Documentation:
Note: At the testing, the last known server time is modelled.
When you launch terminal, Hour() stores the hour of the last_time a tick was received from the broker. This hour_value wouldn't change while the terminal is opened. Last_known_server_time may_not technically be the last time a tick was received however that's the easiest way I can think of explaining it.
I don't think I understand what you actually mean. The way I read what you quoted and wrote, you are saying that: Hour() stores the hour of the last time a tick was received by the terminal and Hour() doesn't change while the terminal is open. If that is what you meant to say and meant to convey (please correct me if I misread what you said), then, respectfully, I believe you might be mistaken.
Hour() returns a integer which represents the hour component of the last known server time. If the last known server time is 10:59, then Hour() returns 10. If the last known server time becomes 11:00 on the next tick, then Hour() returns 11.
I believe the documentation is vague due to translation or has been mistranslated. I believe "the moment of the program start" means the moment start() begins executing and "the time of the program execution" means during the execution of start(). This understanding would be congruent with the behavior that any incoming ticks are ignored while start() is executing. EDIT: This view seems to be conveyed in the Book:
Seconds (), Minute(), Hour(), Day(), TimeMonth(), TimeYear(), DayOfWeek () and DayOfYear() Functions
This is the group of functions that return the current second, minute, hour, day, month, year, day of week and day of year for the last known server time. The last known server time is the server time that corresponds with the moment of the program launch (launch of any special function by the client terminal). The server time is not changed during the execution of the special function.
I use Hour() is my EA without any problems, even though some have suggested (see, for example, here) that Hour() hasn't performed correctly in the Strategy Tester in the past. Currently (build 509), Hour() works correctly in the Strategy Tester.
Here is a small test in the Strategy Tester for 09/11/2013:
You mean he should be MathMod'ing for 24 right?
i was meaning this
Where you have Hour() replace it with TimeHour( TimeCurrent() )
first part only, is this enough.?
As you can see in the message of RaptorUK: what was replied
was not written only first part but Where you have Hour()
So NO how can you ask this question ... with Replying the answer
And yes also it's not TimeHour(TimeCurrent())
it has to the right timezone so you see GMT
in other case
...
that might be like something you see here
As Thirteen has pointed out, I don't see why Hour() wouldn't work
Maybe the problem is elsewhere in the code?
Why does the code return(0) when the if condition is met?
. . . I don't see why Hour() wouldn't work
Maybe the problem is elsewhere in the code?
I believe the code does work. The code below . . .
. . . produces the following output in the journal/log:
So, I think the OP needs to be more specific about what doesn't work and probably needs to post more of his/her code. Also, as GumRai has pointed out, the OP's original code doesn't compile because the extern needs to come before the int declaration.
The above code produces the same output as above.
@Thirteen: I stand corrected. It was one of those things which was changed over time. It is modeled correctly in the tester now. When I went through the book and used Hour() [in strategy tester] it give me the hour from the last Friday or when I disconnected the terminal. Therefore I stopped using it. I'm obviously not alone in this. Just what I'm hardwire to remember. lol.
Added: **I cannot help but say it** If metaQuotes would put something as simple as Below on the Documentation page. Perhaps there wouldn't be such contradiction between Old_School and New_School on this forum. With all the new changes to come, I imagine its just gonna get worse.
Sure they post a [ MetaTrader 4 Client Terminal Built ], but those are posts which floats for about a Week and its harder to remember which change came within which built.
As Thirteen has pointed out, I don't see why Hour() wouldn't work
Maybe the problem is elsewhere in the code?
Why does the code return(0) when the if condition is met?
Thank you guys !
I run BT in mt4 v 4.8.2 and it works also with hour() function aslong I did not add "+GMToffset"
this one is working well also if GMToffset changed
I know TimeHour(time) works so I suggested what does work rather than something which I know has caused issues in the past . . . perhaps the OP was having problems live and not in the Strategy Tester. What does "Returns the hour (0,1,2,..23) of the last known server time by the moment of the program start (this value will not change within the time of the program execution)." mean ? is the program execution the execution of the whole EA/Indicator or just start() ?
I use this code in my EAs to find the current server time for checking session times and also to update a label so that I can always see the current server time. I have not had any issues and it updates the time every tick. If I use the EA in the strategy tester, visual mode, the time is updated with no problems.
I tested this bit of code and left it running
00:01:25 Hour EURUSD,H1: Hour is 17
00:01:25 Hour EURUSD,H1: TimeHour is 17
01:01:33 Hour EURUSD,H1: Hour is 18
01:01:33 Hour EURUSD,H1: TimeHour is 18
02:01:42 Hour EURUSD,H1: Hour is 19
02:01:42 Hour EURUSD,H1: TimeHour is 19
03:01:50 Hour EURUSD,H1: Hour is 20
03:01:50 Hour EURUSD,H1: TimeHour is 20
I don't doubt that there have been issues in the past. The question is whether we can assume that those issues have now been resolved in MT4 now?