Hi QC community,

I am wondering how to implement a function that takes profit based on how much the portfolio has grown in a single day. For example, if my position size is x, and I want to liquidate when my portfolio hits its starting value + 5% profit on the position (can't use unrealized gains as I trim positions frequently, so would not work), how would I write the code to implement this?