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/

    Indicator on monthly data, trading on daily data

    Indicators/Strategies/Analyzers
    data feeds indicator
    3
    5
    295
    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.
    • A
      andi last edited by

      I am looking for advice with respect ot the following scenario:
      I would like to compute an indicator, let's say SMA, on monthly data. The actual trading will take place at the first day of the month. I could use the monthly OHLC data for the strategy as well, however, I would like to use daily data in order to get a realistic analysis of daily returns/drawdowns etc.

      So, my question is how to tackle this problem? Should I use two different time series (daily and monthly)?

      1 Reply Last reply Reply Quote 0
      • R
        rajanprabu last edited by

        @andi

        Cant you simply load daily candles and resample to monthly Timeframe.. trade can be done in daily timeframe while signal comes from monthly timeframe.

        A 1 Reply Last reply Reply Quote 0
        • A
          andi @rajanprabu last edited by

          @rajanprabu I am not totally sure how to proceed from here.

          Am I supposed to add the same data twice, first the regular daily data, and secondly the resampled monthly data?

          cerebro.adddata(data) 
          cerebro.resampledata(
              data,
              timeframe=bt.TimeFrame.Months,
              compression=1
          )
          

          Can I then access the data via datas[0] and datas[1]?

          Would it also be possible to resample the daily data in the strategy's init method when defining the indicator?

          sma_monthly = bt.SimpleMovingAverage(self.data.close)  # How to resample here?
          
          run-out R 2 Replies Last reply Reply Quote 0
          • run-out
            run-out @andi last edited by

            @andi Have a look at the docs here. There are many articles on this topic as well in the community and online. Have a look and let us know how you get on.

            RunBacktest.com

            1 Reply Last reply Reply Quote 0
            • R
              rajanprabu @andi last edited by

              @andi

              simply use datas[1] for monthly sma.

              sma_monthly = bt.SimpleMovingAverage(self.datas[1].close) 
              
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors