How to find the number of bars in a given day

I am exploring AFL. i need to find number of bars exist in a particular day. I got the logic to write but my syntax is wrong. Is there any correct approach to find the number of bars in a particular day?

for (i=0;i<BarCount;i++)

  if (Day()== DateTime(today))
      Count = Count+1;




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
/// similar to
/// @link
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
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 );


You have to start thinking in terms of Array processing