Calculating "days since equity high"

Hi

i have been printing the bars since last equity high in the backtest report with no issues. Now i want to print the days since equity high. The code below is where im at currently. I’m not sure how to set the previous high to a day if that makes sense.

Basically it is printing days since 1900.


StaticVarSet("Low" + Name(), Low); // In regular code

eq = Foreign("~~~EQUITY", "C");
cash = Foreign("~~~EQUITY", "L");
dr = eq - Highest(eq);
bslh = HighestBars(eq);
//---------------------------------------------------------------------------------
lh = StaticVarSet("High", bslh == DaysSince1900());
 // trying to set lh to the day when equity was highest


//-------------------------------------------------------------------------------------

SetCustomBacktestProc( "" );

if ( Status( "action" ) == actionPortfolio )
{
    bo = GetBacktesterObject();
    // run default backtest procedure without generating the trade list
    bo.Backtest( True );

    // iterate through closed trades
	for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
	{
	LowArray = StaticVarGet("Low" + trade.Symbol);
	LowAtEntry = Lookup(LowArray, trade.EntryDateTime);
	trade.AddCustomMetric("Low At Entry", LowAtEntry);
	bs = Lookup(bslh,trade.ExitDateTime);
	trade.AddCustomMetric("Bslh",bs);
	dayshigh = Lookup(DaysSince1900()-lh,trade.ExitDateTime); // trying  to calculate days since eq high
	trade.AddCustomMetric("Days since eq High",dayshigh);
	}

    // generate trade list
    bo.ListTrades( );

}

Thanks