-
If you had used this (before posting), you would have found thousands of answers.
-
You can't know when a candle closes. Only when a new tick arrives that starts a new bar is the old bar closed.
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
MT4: New candle - MQL4 programming forum #3 (2014)
MT5: Accessing variables - MQL4 programming forum #3 (2022)I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, all!
I currently have a burning question.
When back-testing an Expert Advisor I use the OnTick() function to check for the entry/close signal. This works fine when back-testing on Open Prices Only, however I know that this won't be the case when it will be set up on a live environment since it will be checking it for every tick that I receive. So my question is, what function or approach should be used to check for entry/exit signal only when a new 1H (or any other timeframe) candlestick opens?
For the record, I have looked around for solutions and found a possible ones, but would love to hear some comments/ideas on this issue.
Many thanks! :)
Best regards,
AV