For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Make ticks on edges count as open for next bar (instead of close of current bar)

  • Hello gentlemen,

    I am back at this topic (everyhing I say is based on my current understanding, please feel to comment if I am wrong somewhere):
    When resampling ticks to a higher timeframe then currently backtrader counts ticks on the edge (e.g. 14:00:00 when Tick -> Hour) as last (closing) value for the current bar. This intentionally as far as I know.
    I was expeceting (since I know it from other software packages) that such ticks would count as the open value for the following bar.

    I had a topic about this here already (I thought it was a bug back then):

    So I tried to change the backtrader code to make it behave like I am used to. I did it with this commit which touches backtrader's Resampler filter:

    The commit adds a parameter tickedgestart to the Resampler (defaults to False). When setting to True then the alternative behavior is activated (only when resampling Tick). So far it does what I wanted for me.

    Please @backtrader would you maybe take a look at the commit and tell me if you see problems with that approach? I feel that I don't have a well enough understanding of the internals to be sure to avoid side effects. :(

Log in to reply