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
I believe the right code is:
if (iTime(NULL, 0, 0)
However as soon as I add this code, the compiler starts saying that there are { in the wrong place and always too many or too few. When I remove the code if (iTime(NULL, 0, 0) everything is fine again...
Any suggestions?
Hello,
I made a simple EA but to speed up optimization I want to make the EA opena new trade only when the indicators are right and only when a new bar starts.
The EA has to wait until the bar closes and then opens a new trade only when the new bar opens.
Could someone tell me the code to use? I believe it will be something like if bar opens but I am sure and I can't find the info online.
Thank you
Hi
This simple script detects the start of a new BAR but it does only works if the price/volume has changed during the BAR period.
Maybe you can use it.
Awesome! It works for me like a charm!
Thanks for your input.
How can a newcomer learn to create an EA?
Hi @Olawale Daniel
Please see: https://www.mql5.com/en/docs
And you can also try codebase for example code: https://www.mql5.com/en/code
Hi
This simple script detects the start of a new BAR but it does only works if the price/volume has changed during the BAR period.
Maybe you can use it.
prev_calculated undeclared identified, where and how to define it
Simple? 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