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)
static MqlTick last_tick[3];
last_tick[2] = last_tick[1];
last_tick[1] = last_tick[0];
... continue with your code as posted ...
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)
as it is impossible is there a way to program in 1 second to take the price at the close of each 1 second candle?
Thanks
Perhaps you should read the manual. Client Terminal Events - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5#Timer
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
- 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 engineers
I have a small problem that I would like your help :
it doesn't produce what i want
Thank you in advance for your help.