I think I fixed the problem. But this block is complicated and it's possible that this fix can break something else. Tell me if you find something that doesn't work as expected.
Today I decided to clear some errors and now MQL4 files are generated in strict mode. Also because I optimized some code, now backtests are little bit faster (well, it depends what blocks are used)