Thanks for you quick responses.

This is minimum error reproducible code. I am using version Amibroker 6.49.1 x64

```
SetBarsRequired( sbrAll, sbrAll );
EnableTextOutput(False);
mode = ParamToggle( "Box Mode", "Auto|Manual" );
atrper = Param( "ATR Period", 14, 2, 100, 1 );
boxper = Param( "Boxsize(%ATR)", 5, 0.1, 20, 0.1 )/100;
boxsize = Param( "BoxSize(Points)", 50, 0, 1000, 0.05 );
startdate = ParamDate( "Start Date", "01-01-2024", 0 );
// calculation for auto mode
TimeFrameSet(inDaily);
ydatr = Ref(ATR(atrper), -1);
TimeFrameRestore();
ydatre = TimeFrameExpand(ydatr, inDaily, expandFirst);
if(!mode)
boxsize = LastValue(ydatre)*boxper;
// global values
spread = 0.05;
tn = TimeNum();
dn = DateNum();
bi = BarIndex();
lbar = BarCount - 1; // last barindex of chart
fc = dn != Ref( dn, -1 ); // day's first bar flag
lc = Ref(fc, 1) OR (bi == lbar); // day's last bar flag
fcbi = ValueWhen( fc, bi, 1 ); // barindex of first bar of day
lcbi = ValueWhen( lc, bi, 0 ); // barindex of last bar of day (in future)
ibar = LastValue( ValueWhen( dn >= startdate AND Ref( dn, -1 ) < startdate, bi, 1 ) ); // barindex on start date first candle
relbi = bi - fcbi; // relative barindex from day's first bar
boxsize = round( boxsize / spread ) * spread + 1e-20; // boxsize roundoff and avoiding division by zero
hh = LastValue( HHV( H, lbar - ibar + 1 ) ); // highest price in given history
ll = LastValue( LLV( L, lbar - ibar + 1 ) ); // lowest price in given history
last_box_high = round( hh / boxsize ) * boxsize + boxsize/2; // high level of top most box
first_box_low = round( ll / boxsize ) * boxsize - boxsize/2; // low level of bottom most box
rows = int( ( last_box_high - first_box_low ) / boxsize ); // total price box for matrix definition
cols = lbar - ibar + 1; // total bars for matrix definition
// initializing matrices and array values
// the following loop will fill all the matrices and arrays
boxl = Matrix( rows, cols, -1 ); // matrix for box low level
boxh = Matrix( rows, cols, -1 ); // matrix for box high level
boxp = Matrix( rows, cols, 1e20 ); // matrix for box price profile set to 1 or 0
boxtpo = Matrix( rows, cols, 1e20 ); // matrix for box time price opportunity
boxdpd = Matrix( rows, cols, 0 ); // matrix for box showing daily price distribution on first bar only
boxdpp = Matrix( rows, cols, 1e20 ); // matrix for box showing daily price profile
```