Let use a better example. see the below code. The exploration (see screenshot below) is run in periodicity 10 minutes with the data attached below.
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}} ", O, H, L, C, SelectedValue( ROC( C, 1 ))) );
PlotOHLC( O, H, L, C, "Traded", colorRed, styleBar , Null, Null, 0, 1, 1);
_SECTION_END();
_TRACE( "!CLEAR!" );
_TRACE("barindex()="+barindex()); //532, 132
HigherThanPrevious5=H>Ref(HHV(H,5), -1);
BarIndexFutCondition=ValueWhen(HigherThanPrevious5, BarIndex(), 0);
_TRACE("BarIndexFutCondition="+BarIndexFutCondition+", HigherThanPrevious5="+HigherThanPrevious5+", isnull(HigherThanPrevious5)="+isnull(HigherThanPrevious5));
PlotShapes( IIF( HigherThanPrevious5, shapeSmallCircle, shapeNone ), colorYellow, 0, L - ATR(5)/3);
Filter=1;
AddColumn(BarIndex(), "BarIndex()");
AddColumn(HigherThanPrevious5, "HigherThanPrevious5");
AddColumn(BarIndexFutCondition, "BarIndexFutCondition");
Get data here https://uploadnow.io/f/Ksy1dsn
The question is why valueWhen returning blanks for the first few bars?