Here is an example of the view and the code;
Coding;
extern int maxBars = 400;
int start() {
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if ( limit > maxBars )
{
limit = maxBars;
}
MRtools would be a better source of MAXBARS coding . I'm sure he would be glad to assist.