Seems like it's got nothing to do with bars loaded rather the amt of data in the database. Now the problem is how to restrict a particular operation (iteration for e.g.) to the no. of bars loaded.
Off course it can be done by setting n (no. of iterations) = 1000, but i'd like something more generic like n = BarsLoaded() or GetBarsLoaded().