What is the Timezone of the broker? Does it coincide with those hours?
Remember that the "Hour()" function returns the Server time and not your local time, so maybe you will need to offset that so that it matches the required time.
I don't believe that the Hour() function does not work on Daily charts! However your function may be only triggered once a day at the beginning of the bar if your code is detecting a New Bar and only executing it then.
Is that the case? Are you using a New Bar detection in order to only run certain parts of the code only once per bar?
If so, try calling it directly from the OnTick() event, just to see if that is the case.
Also, have you tested your EA on an Hourly Chart just to check if it behaves differently?
I don't believe that the Hour() function does not work on Daily charts! However your function may be only triggered once a day at the beginning of the bar if your code is detecting a New Bar and only executing it then.
Is that the case? Are you using a New Bar detection in order to only run certain parts of the code only once per bar?
If so, try calling it directly from the OnTick() event, just to see if that is the case.
Also, have you tested your EA on an Hourly Chart just to check if it behaves differently?
Well, you have just described the problem and the solution. If you are indeed running the code within the "New Bar" code block, then it is NOT going to work for time-frames higher than H1.
You have to run that "MaretHours()" detection code outside of that "New Bar" block, either at every Tick or create an equivalent "New Hour" detection code block for that function.
Well, you have just described the problem and the solution. If you are indeed running the code within the "New Bar" code block, then it is NOT going to work for time-frames higher than H1.
You have to run that "MaretHours()" detection code outside of that "New Bar" block, either at every Tick or create an equivalent "New Hour" detection code block for that function.
It's outside actually.
Given that it works on the H1 Chart and not on the Daily chart, then the "MarketHours()" function is definitely not being called on every tick or maybe there is other logic that is affecting its impact.
So, without any other code provided by you for us to be able to analyse and see where the logic problem may be, it will probably be impossible for us to be able to help you further.
What I can suggest, is that you run the code in DEBUG mode via MetaEditor, or add plenty of "Print()" statements at various points, in order to be able to trace the execution and thus detect where the logic may be failing.
Alternatively, if you know another coder that you trust enough to share you code with, have them have a look at it. An extra pair of eyes may be able to see the problem!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone, I have an EA based on making trades on daily chart.
The problem is that whenever i start it, the journal doesn't send me a report of the EA being initialized at a specific time.
Here is my code with printf statements. Only the "ea is not ready" string is being shown.