-
datetime t_0, prev_time; if(prev_calculated==0 && prev_time==0)
- You properly used strict. Therefor, prev_time has a random value and your if can fail.
- Why are you saving the time? Rates_total and prev_calculated is all you need.
How to do your lookbacks correctly #9 — #14 & #19 (2016)
-
i = (Time[0] - prev_time)/PeriodSeconds();
This assumes every bar every exists — they don't. 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 (2006)
No candle if open = close ? - MQL4 programming forum (2010)Use Rates_total and prev_calculated
Thank you! I have fixed it.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 made an indicator an indicator to plot vlines on every candle but when closing the MT4 and opening it again after some time, there is also gap where there is no plotted vlines. See image below:
I closed the MT4 then open it again after 3 minutes.
Here is the code:
Please help fix the missing values on other candles. Thanks!