For time based thing, use OnTimer. You want "every bar," use tick based (OnTick) and test for a new bar.
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 and MetaTrader 4 -
MQL4 programming forum.) Always use time.
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 and MetaTrader 4 - MQL4 programming forum
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 and MetaTrader 4 - MQL4 programming forum
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
Hi experts.
If I want to add value to x variable every bar in function ontimer. How to code it?
Such as in TF H1,Ontimer,and x+1 every bar
at 6:00 , I set x to 0.
7:00 x =1
8:00 x=2
9:00 x=3
thank you very much