@fivo said in Order Validity:
If you want to make it dependent on your data, pass timeframe_in_m to your strategy.
Data feeds have a parameter named timeframe which carries the original value when the data feed was created. Using it (rather than an extra parameter) together with the chosen compression, you can get it ...
auto_timer = dict(
bt.TimeFrame.Seconds=lambda x: datetime.timedelta(seconds=x),
bt.TimeFrame.Minutes=lambda x: datetime.timedelta(minutes=x),
bt.TimeFrame.Days=lambda x: datetime.timedelta(days=x),
)
nextbar = self.data.num2date() + auto_timer[self.data.p.timeframe](self.data.p.compression)
Notice self.data.num2date() which
If no numeric value is given uses the current value from the datetime line (i.e.: self.lines.datetime[0])