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/

    How to implement dualthrust with backtrader

    General Code/Help
    2
    2
    623
    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.
    • Y
      Yelloww last edited by

      Dualthrust is quite a simple idea, but I failed to implement it with backtrader.

      My first approach is use built-in indicators to form a dualthrust system.
      I tried backtrader.indicators.Lowest and Highest in an attempt to get the highest/lowest of the previous high/low/close prices. However, these indicator does not let you specify field (high, low, close). And I am not sure it is calculating highest/lowest in a rolling manner.

      2nd approach is to create a customized indicator class. Multiple questions here: data is not in pandas format, I dont even know how to get high/low prices for a specific period. In addition, I have 2 data timeframes, seconds and daily. Indicator only needs to be calculated daily, but I believe the "next" method in the indicator class will calculate it every second, which is inefficient.

      Can anyone tell me how to use built-in indicator to make up a dualthrust indicators? Or give me an example indicator class which just calculate in a daily basis the rolling maximum high price for a rolling window of N?

      Thank you.

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        It would be nice to have a description of the system you want to implement. At least if you are waiting an advice.

        Built-in Highest and Lowest indicators calculates max/min prices for N last bars (rolling manner). Not sure why do you think other way.

        Add daily data feed and apply your indicator to this data feed, it will give you daily values, they should be the same on all intraday bars of the day.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors