How to implement dualthrust with backtrader
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?
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.
Lowestindicators 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.