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

How to implement dualthrust with backtrader

  • 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.

  • 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.

Log in to reply