If you build M5 bars from M1 data in pandas and compare them with the platform's chart, a one bar difference is common. This is the cause.
I used a toy frame with the M1 open prices 1.0, 2.0, up to 12.0 starting at 10:00, so you can see which bar went where.
Code: Select all
ohlc = {"open": "first", "high": "max", "low": "min", "close": "last"}
m5 = m1.resample("5min").agg(ohlc)
m5r = m1.resample("5min", label="right", closed="right").agg(ohlc)
With label and closed both set to right, the bar stamped 10:05 contains 10:01 to 10:05, opens at 2.0, and the very first 10:00 bar sits alone in a bucket labelled 10:00. At the end of the data there is a partial bucket labelled 10:15 holding only the 10:11 bar. Every M5 candle then differs from the platform's, and a strategy that looks at closes sees a different number.
It goes wrong when someone copies a snippet for daily or weekly data, where right labelling is conventional, and uses it for intraday bars.
Check one bar by hand against the chart before running anything on the full data.