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

Using ParabolicSAR inside strategy

  • Good morning,
    I'm having difficulty implementing the ParabolicSAR in my strategy. I believe I've done the params and initialization correctly (not for sure, though), but I'm not sure how to add the conditions in. Am I supposed to build the calculations and use a variable for the condition? Or is that done inside backtrader? I want to include a psar condition inside the buy/sell conditions.


    ('period', 2), # psar period ('start' in pine)
    ('af', 0.005), #psar af ('increment' in pine)
    ('afmax', 1), #psar afmax ('maximum' in pine)


    self.psar = bt.indicators.ParabolicSAR(
                period = self.p.period,# Period
                plot = False,
                af =,
                afmax = self.p.afmax,

    I am new, thank you for your patience.

  • I have searched google and backtrader references with no luck. I may just need a point in the right direction.

Log in to reply