Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Resampled candles is different than on chart

    General Discussion
    1
    5
    202
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dt last edited by

      Hello,
      I can't understand why when I use resampled data, the plot shows differrent candles than on the chart (TradingView).

      Here is the screenshot below (the top row is not resampled 1m data, the bottom is resampled with compression=60)

      alt text

      1 Reply Last reply Reply Quote 0
      • D
        dt last edited by

        cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=60)
        
           ...
        
        # Plot the result
        cerebro.plot(style='candle')
        
        1 Reply Last reply Reply Quote 0
        • D
          dt last edited by

          Here is csv data I used: data.csv

          On 2020-06-09 00:15:00 price hits 9876 (highest price on the chart)

          On TradingView it shows at "00:00" candle, but on the plot from BackTrader it shows only at "01:00" candle.

          It was compared with the 1h data from https://en.tradingview.com/chart/?symbol=BITFINEX%3ABTCUSD for 09 Jun 2020.

          1 Reply Last reply Reply Quote 0
          • D
            dt last edited by

            I solved this by adding

            1 Reply Last reply Reply Quote 0
            • D
              dt last edited by

              I solved this by adding "boundoff=1"

              cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=60, boundoff=1)
              

              Now is shows exactly as on TW platform. alt text

              1 Reply Last reply Reply Quote 2
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors