Trailing Stop Loss Beginner
I am a beginner just trying to learn how to use backtrader. I have tried several times and looked at the documentation for adding a trailing stop loss but can't seem to figure it out.
Here is my simple test code:
def __init__(self): ema3 = bt.ind.EMA(period = 3) ema5 = bt.ind.EMA(period = 5) ema50 = bt.ind.EMA(period = 50) ema60 = bt.ind.EMA(period = 60) cmin = bt.Min(ema3,ema5) cmax = bt.Max(ema50,ema60) self.crossover = bt.ind.CrossOver(cmin, cmax) def next(self): if not self.position: if self.crossover > 0: self.buy() elif self.crossover < 0: self.sell()
Can anyone explain how to add a trailing stop loss that trails by a 1%?
run-out last edited by
@newtrader15 Can you please include all your code. Thanks
Yesterday I said to my friends that this site is the best option for modern students. Everyone should read this reviews because this is important.