This error:
Error 046:IDX LookBack exceeded by 397 bars (477)

if I set LookBack it just adds that number to the LookBack period, keeping the error.

The code that causes the error is in the TMF:
for(current_trades) {
barhour_open=hour(TradeBarOpen);
barminute_open=minute(TradeBarOpen);

}

that is to say, using TradeBarOpen crashes the program.
why?

the intention behind the code is to create an exit condition if trades are open longer than a certain period, ie:

totalminutesatopen = (hour(TradeBarOpen) * 60) + minute(TradeBarOpen);
totalminutesnow = (hour() * 60) + minute();
tmdiff = totalminutesnow - totalminutesatopen;
if (tmdiff >= 180) {
return 1;
}

this alone throws up weird results (i can run the code by setting LookBack to 0; a trade recursion warning is inexplicably thrown-up). even though TICKS are set (BarPeriod = 1) and the data is t1 downloaded from zorro website, meaning the TMF should be called each tick, the next time the code is run, many hours have passed. A trade at hour 7 for example, TMF spews out hour 23, missing thousands of ticks.

not what was expected.