Do not use array functions within barcount loop.
First read understanding how AFL works.
Besides similar threads exist
Few days ago:
So changing just very few things
/// @link https://forum.amibroker.com/t/how-to-find-the-number-of-bars-in-a-given-day/11057/2
/// similar to
/// @link https://forum.amibroker.com/t/filter-low-volume-activity-stocks/10982/4
my_date = "2019-01-16";
//
bi = BarIndex();
dn = DateNum();
newday = dn != Ref( dn, -1);
//
StartBI = ValueWhen(newday, bi, 2);
EndBI = ValueWhen(newday, bi, 1);
bars_yesterday = EndBI-StartBI;
Condition = Ref(dn,-1) == DateTimeConvert(0, _DT(my_date)) AND newday;
printf( "#Bars of date: %g", ValueWhen(condition, bars_yesterday));
/// @link https://www.amibroker.com/guide/h_exploration.html
Filter = Condition;
AddTextColumn(Interval(2), "Interval", 1);
Addcolumn(bars_yesterday, "#Bars of date " + my_date, 1 );
Plot( C, "Price", colorDefault, styleCandle );
And if you want to get bars of today then it is just
dt = DateTime();
dn = DateNum();
newday = dn != Ref( dn, -1);
bars_of_today = BarsSince(newday) + 1;
Filter = Status("lastbarinrange");
// or use
//Filter = Status("lastbarinrange") OR newday; // for every day bar number
SetOption( "NoDefaultColumns", True);
AddTextColumn( Name(), "Ticker" );
AddColumn( IIf( newday, Ref(dt, -1), dt), "DateTime", formatDateTime);
AddTextColumn(Interval(2), "Interval", 1);
Addcolumn(IIf( newday, Ref(bars_of_today, -1), bars_of_today), "#Bars of intraday", 1 );