Hello!
You will need a separate trigger that adds up profit using a trigger variable. This trigger will be executed in settled markets and check if the market's settled P/L is greater than 0.
Then it will use the profit variable in the formula for the bet amount:
resp/(lay_price-1) + profit