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
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
So what can be used pls for MQL5?
You cannot rely on PositionsTotal: you sent a trade order, this trade order is being processed for some time (checked, registered with a broker ...)
While a trade order is being converted to a position, you can get several ticks - and all these ticks PositionsTotal will show '0'.
How I overcome this problem: I send a trade order and wait for the result in OnTradeTransaction (I called such a system barabashkakvn Trading engine 3.XXX )
You cannot rely on PositionsTotal: you sent a trade order, this trade order is being processed for some time (checked, registered with a broker ...)
While a trade order is being converted to a position, you can get several ticks - and all these ticks PositionsTotal will show '0'.
How I overcome this problem: I send a trade order and wait for the result in OnTradeTransaction (I called such a system barabashkakvn Trading engine 3.XXX )
Thanks, my problem is a bit smaller. I only want to initiate trade at the open of the next bar candle after my conditions have been met. Been googling alot and the different solutions are driving me mad.
Example: iRSI simple advisor

- 2020.03.05
- www.mql5.com

- 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 friend,
I am new to Mt5 coding. I need help to add a functionality to this EA.
when signal is generated it opens new position at the next tick price. // I do not want this
It should open position only at the opening on next candle.
Here is the code is have