Relative Content

Tag Archive for backtrader

Incomplete Bracket Order (TP set later)

In my algorithm, I can set the TP only when my buy/sell limit has been filled. More specifically, the tp only can be calculated when the current market price is around the buy/sell limit price.
I am using a code like the following to implement this. But the target does not work this way.

Access the main plot axis in backtrader

I wand to add custom plot elements e.g. a box between buy and sell trades. The axis ax is normally created like this: fig, ax = plt.subplots()
How can I access it in Backtester’s plot?

How to add min period in strategy?

In most cases we add min period in Indicators and in strategy’s next(), everything is handled properly. But sometimes the strategy is extremely simple so that I don’t want to write a indicator for it. In this case how can I mannully add a min period in strategy? Of course, I can create a dummy indicator in strategy’s __init__ but this seems not elegant at all. I’m considering is there exist any elegant method?