Hi,
I'm a programmer new to MQL and to this forum. Right now I'm trying to trigger the NewTick event for an Expert Advisor attached to a chart on "open prices only" mode --which ticks for every new period for the chosen time-frame (M1, M5, M15, ...)-- so I can make use of the OnTick() function to communicate the OHLC values every -say- hour.
I've been reading throughout the documentation and couldn't figure it out, thanks in advance for any possible remark.
--
Luero
Hi Lucero,
Try to use OnTimer() function or check if Current_Time != Time on Bar 0, because basically we can't generate new tick in live.
:D
Hola onewithzachy,
Thanks for you comment. Look, I've myself found this way around:
long lastbar_date; void OnTick() { if( lastbar_date != SeriesInfoInteger( Symbol(), PERIOD_CURRENT, SERIES_LASTBAR_DATE ) ) { // whatever the code you want to execute on every new bar } lastbar_date = SeriesInfoInteger( Symbol(), PERIOD_CURRENT, SERIES_LASTBAR_DATE ); // "1970.01.01 00:00:00" ???? }
This works pretty well, even if I change the time-frame during the trading, and I can even dismiss the timer. ... well, it would work well but there seem to be something awkward with the last bar date randomly being set on Jan 1970 for no apparent reason (see SeriesInfoInteger("EURUSD",0,5) randomly returning 1970.01.01 00:00:00. bug?). Anyway, that can be circumvented by calling the SERIES_BARS_COUNT instead of the SERIES_LASTBAR_DATE, both are of course related but the bar counts seems to be consistent and not being randomly turned back to the 1970 value.
Hope it helps to anyone dealing with something similar.

- 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,
I'm a programmer new to MQL and to this forum. Right now I'm trying to trigger the NewTick event for an Expert Advisor attached to a chart on "open prices only" mode --which ticks for every new period for the chosen time-frame (M1, M5, M15, ...)-- so I can make use of the OnTick() function to communicate the OHLC values every -say- hour.
I've been reading throughout the documentation and couldn't figure it out, thanks in advance for any possible remark.
--
Luero