Finding daily profit in pine script

I’m using pine script of Trading View for creating strategy. I want to limit my profit for each day to $100, over a series of trades taken combining profit and loss, and then stop trading further for that day, what function could be used for getting daily profit to limit it to 100 in pine script of trading view?

This works, a bit brute force; but it works!

//@version=5
Dailygoal = input.float( title = “Daily profit to stop trading”, defval = 500 )
Maxloss = input.float( title = “Daily max loss to stop trading”, defval = 500 )
strategy.risk.max_intraday_loss( Maxloss, strategy.cash)
//
Closeall = time( timeframe.period, “1630-1700” ) // end of session I used to trigger reset for new session
bgcolor( Closeall ? color.new(color.blue, 25) : na )
//
var Sessionprofit = 0.0
var Sessionstart = 0.0
var Profitmet = 0
PP = strategy.netprofit
//
if Closeall
Sessionprofit := 0
Profitmet := 0
Sessionstart := PP
//
Sessionprofit := PP - Sessionstart
//
if Sessionprofit > Dailygoal
Profitmet := 1
bgcolor( Profitmet ? color.new(color.green, 80) : na )