Skip to content

Commit ba336a0

Browse files
committed
Fix timeframe/compression detection when plotting
1 parent 0ed267b commit ba336a0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

backtrader/plot/plot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,11 @@ def plot(self, strategy, figid=0, numfigs=1, iplot=True,
271271
return figs
272272

273273
def setlocators(self, ax):
274-
comp = getattr(self.pinf.clock, '_compression', 1)
275-
tframe = getattr(self.pinf.clock, '_timeframe', TimeFrame.Days)
274+
clock = sorted(self.pinf.clock.datas,
275+
key=lambda x: (x._timeframe, x._compression))[0]
276+
277+
comp = getattr(clock, '_compression', 1)
278+
tframe = getattr(clock, '_timeframe', TimeFrame.Days)
276279

277280
if self.pinf.sch.fmt_x_data is None:
278281
if tframe == TimeFrame.Years:

0 commit comments

Comments
 (0)