Backtrader works only when resampling interval is divided by session duration. meaning if session duration is 8 hours, one can resample them to 8 1h candles. I think your last 1 h candle will have only 30 minutes. So BT may not resample the way you expect.
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/