- Seconds until end of bar
- set start time of bars??
- Change Strategy Tester Speed (between 31 and 32)?
No, because you never know which tick will be the last one, until you get a new one starting a new bar.
What if there are no ticks during a
specific candle period?
There can be minutes between ticks during the Asian session, think M1 chart.
Larger charts, think weekend, market holiday (country and broker specific.)
requires knowledge of when your broker stops and starts (not necessary the same
as the market.)
"Free-of-Holes" Charts - MQL4 Articles
No candle if open = close
? - MQL4 and MetaTrader 4 - MQL4 programming forum
Is there a way to signal when a bar ends and before the next bar begins?
Yes, it doesn't matter if there is a tick or not you just need to use the OnTimer handler. The first tick after initialization you will set an event timer for the delta of the number of seconds in the period minus the time lapsed since the beginning of the period minus one second. When OnTimer fires you reset the event timer equal to the period seconds so OnTimer will fire one second for the end of each bar in the series.
#property strict int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { EventKillTimer(); } //+------------------------------------------------------------------+ void OnTick() { static bool false; if (!onbar_init) { int lapsed = int(TimeCurrent() - Time[0]); int seconds = PeriodSeconds(PERIOD_CURRENT) - lapsed - 1; EventSetTimer(seconds); true; Print("Set initial timer to ", seconds); } } void OnTimer() { EventSetTimer(PeriodSeconds(PERIOD_CURRENT)); Alert("OnBarEnd"); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use