I am trying to create a holding period for stocks until they satisfy a certain criteria rather than fixed (5 days, 10 days) holding period. I have been searching on how to implement it for a while but have not been able to come across any helpful resources.
Can anyone guide me on how to do it?
Example case: The maximum period to hold a stock is 6 months, however at any time if P/E ratio exceeds a certain fixed limit the stock should be sold.