Bracket order for weekly data
I am trying to create stop loss order for my weekly strategy. Right now, I tried to use the following code
close = d.close p1 = close - 0.05*close p2 = p1 - 0.02 *p1 valid1 = datetime.timedelta(3) valid2 = datetime.timedelta(6) o1 = self.order_target_percent(d, target=self.perctarget , exectype=bt.Order.Limit, price=p1,valid=valid1,transmit=True) o2 = self.sell(exectype=bt.Order.Stop, price=p2, valid=valid2, parent=o1, transmit=False)
The program ran but didn't produce a single trade. I think that's because I'm adding resampled data of tf=bt.TimeFrame.Weeks. The limit orders never got executed because backtrader only sees weekly data and these trades are only valid for valid1 time. To solve this problem, I tried to change the timeframe to days but then the strategy messes up because I need the weekly values of indicators and it then gives me daily values of the indicators even when I execute the trades on a single day in a week. How to solve this issue????