Loop and Multi TimeFrame

Code like this....

//variable initialization
......
......
TimeFrameSet(inHourly);
//start = NullCount( Close );   //needed???????????
BarToLoop = IIf(BarCount>200,BarCount-200,1);
for ( i = BarToLoop; i < BarCount; i++ )
{
......
......
}
Lplot = LineArray(.....);
TimeFrameRestore();

Plot(TimeFrameExpand(Lplot,inHourly),...........);

Some 30 shares in database(of 1min interval)....
Code work fine on Hourly chart....
When change to other TimeFrame says 30min or 15 min or ... everything good...
but except 3 / 4 chart whose database less than one and a half month... give bizarre result.
What the reason for such strange result cant able to figure out ...:exploding_head:

Read here where it says:

If using timeframe functions then initial bars (bars at start of array) are filled with Null due to compression. So you need to skip those Null occurrences in your loop.

startbar = NullCount(array, 1);

for(i = startbar; i < BarCount; i++) {
    //....
}

Also you need to take care of QuickAFL if using loop to get enough data creating longer interval bars in your chart.

10 Likes

@fxshrat
I don’t use SetBarsRequired()....
Quick%20afl
In main database code runs well without any problem.... :smiley:

This database download from internet… everything looks good except 3 to 4 shares.
change this within code...

BarToLoop = IIf(BarCount>200,BarCount-200,1);
startbar = NullCount(Close, 1);
for ( i = Max(startbar,BarToLoop); i < BarCount; i++ ){
    //.......
}

but 3/4 shares bizarre act... not stop.

@fxshrat
Thanks... problem solve. :smiley:
Within loop… using first bar value as reference point. After above modification…. forgot to change there.