Today I investigated this error a little bit more. One user sent me his history data and I was able to get the error myself. At the end, I don't know how to fix the problem, but this is what I understood.
Each candle has OHLC, Volume and also Time. "Once per bar" works by reading the Time from the candle, remembering that time and then when the time changes (when a new candle is added), it can pass again and remember the new time. Do this over and over and the block passes once per bar.
To get the time I used a function called CopyTime. This function would read the data from just one candle, and then it would put the result in a dynamic array, which initially has size of 0. When the data is put into the array, its size would automatically change to 1. Then, that single value from the array would be read, which usually happens without problems. But when the function fails, the array doesn't change, its size remains 0 and that's why later it shows "array out of range".
While the error says "array out of range", the problem comes from the inability to read that candle. And in the tests I did today, CopyTime wasn't able to read any candle.
First I did a fix, so that when CopyTime fails, it won't even try to read the value from the array, it would just do nothing and "Once per bar" won't pass. Muted error, the EA just tried to do what it can.
Then I tested iTime, which seems to be able to get the time from the previous candle somehow. However, then I realized that if lower timeframe is selected in "Once per bar", then iTime (and also CopyTime) could fail.
So the whole situation happens because something in the history data is not right. But I don't really know how to fix the problem with these functions. I can mute the error so it won't appear, or print another more descriptive error.