Apparently, (post all relevant code like in which function) that code is being called per tick. Call it once per 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 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 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 programming forum
void OnTick() { double Price1 = iClose("USDCHF",1,1); double Price2 = iClose("USDCHF",1,2); }
Thanks for your help,
I think I found something that works.
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
When I test this in the strategy tester the result is hundreds of numbers zipping by per second. I am trying to get one number every 4 hours.
I think a period() or PERIOD_CONSTANT is needed but I don't know where to start. The definitions from the documentation are not enough and of course I'm sure this questions has been asked before.
Where can I find a tutorial to do this?
Thanks.