Days Since Recent Buy Signal

I have the following section of code in my Analysis window:

SetOption("nodefaultcolumns",1);
AddTextColumn(Name(),"Name");
AddColumn( DateTime(), "Date / Time", formatDateTime);
AddTextColumn (" "," ");
AddColumn (Buy111, "_BUY", 1,iif(Buy>0,colorGreen,colorWhite));
AddColumn (Sell
111,"_SELL",1,iif(Sell>0,colorRed,colorWhite));
AddColumn (Ref(Close,1),"Close",4.2);
CloseNow=Ref(Close,9999);
AddColumn (CloseNow,"CloseNow",4.2);
AddColumn (((CloseNow/Ref(Close,1)-1)*100),"CloseNow%",4.2);
SetSortColumns( 3,-2,1 );

I'd like to compute the number of days from the most recent Buy signal until today (when I run Explore) so that I can calculate and display ROI.

Can anyone help?

Many thanks in advance.

Would "ValueWhen" be the function that you need?