Horizontal Scroll Interval

Hi, I'm currently working with tick based charts and would like a method for setting the horizontal scroll distance. Utilizing some of the KB articles led to the code below which gets close but the spacing between the bars does not remain constant (eg, the chart could be set to show 500 bars, but after the scroll function executes, it will show only 200 bars). I assume this is because several ticks can have the same timestamp(?) although with sub-second resolution this shouldn't be a problem. So I'm baffled. It would be great to have this functionality coded directly into AmiBroker and included in the options dialog.

Any ideas?


dt		= DateTime();
vk_Left = 37;

if( GetAsyncKeyState( vk_Left ) < 0 ){
	Title = EncodeColor(colorRed) + "PRESSED - MOVE BACK ONE SCREEN";
	if( DateTimeDiff(Now(5),Nz(StaticVarGet("svLastKeyPress"))) > 3 ){
		lvbi0	= Min(BarCount-1,Status("lastvisiblebarindex"));
		fvbi0	= Status("firstvisiblebarindex");
		range	= Max(lvbi0-fvbi0,500);     // this doesn't ensure 500 bars on the chart
		lvbi1	= fvbi0+5;
		fvbi1	= lvbi1 - range;
		lvdt 	= dt[lvbi1];
		fvdt 	= Max(dt[fvbi1],0);
		ldtStr	= DateTimeToStr( lvdt );
		fdtStr	= DateTimeToStr( fvdt );
		AB		= CreateObject("Broker.Application");
		AW		= AB.ActiveWindow;
		AW.ZoomToRange( fdtStr, ldtStr );