My AFL code is below which needs to find the bar at which the expression occurs.

bi = BarIndex();

Period = 50;

FirstHighest = HHV(H, Period);

FirstLowest = LLV(L, Period);

FirstHighestBarIndex = ValueWhen(H == FirstHighest, bi,1);

FirstLowestBarIndex = ValueWhen(L == FirstLowest, bi,1);

Filter = 1;

AddColumn(FirstHighest, "FirstHighest", 1.2 );

AddColumn(FirstLowest, "FirstLowest", 1.2 );

AddColumn(FirstHighestBarIndex, "FirstHighestBarIndex", 1.0 );

AddColumn(FirstLowestBarIndex, "FirstLowestBarIndex", 1.0 );

The explorer resuls is as below.

The question is barIndex (FirstHighestBarIndex) results. It gives the results above 7000, but the total number of historical bars available for the given Symbol is only around 400.