Sell when exit conditions are met or trailing stop loss?
Not sure if my question makes sense...
Say I want to do a simple MA crossover strategy for entry and exit.
But I just want to add a trailing stop loss to protect myself, just in case.
How would I implement the sell orders so that I exit my position either when the exit conditions are met (MA crossdown) or when the trailing stop loss is triggered?
At the moment, I have this code, but I am not sure it is actually doing what I intended...
(i.e. it might actually look for trailing stop loss trigger after the crossdown occurs, instead of looking for either a crossdown OR a trailing stop loss trigger)
elif self.order is None: if self.MAfast < self.MAslow: self.order = self.sell(exectype=bt.Order.StopTrail, trailpercent=self.p.trailpercent)
Thanks to this knowledgeable community for helping!