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

Trade markers misaligned with price due to gaps in data?

  • BackTrader,
    In multi-data back-testing, when one data has a gap, the markers for trades after this gap appear to be misaligned with the price data, by the number of bars during the gap. (The actual order and trade records are correct, so this is only a plotting issue.) It appears only happen with multi-data. Please see example graph below. Any advise? Thanks!


  • In the chart above, before the data gap, trades are correctly marked on the bar after the signal bar (Crossover=1/-1), but after the gap, it is marked on the second bar after. Anyone who can help? Thanks in advance!

  • administrators

    Plotting was only meant as a visual aid and not as exact representation. The limitations on the alignment of axis which are inherent to matplotlib (or maybe to the lack of understanding of the many underlying complexities lurking in such a complex package) make it impossible to achieve a perfect alignment.

  • Thanks, hope there is way to fix it in the future.