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

How to set strategy's member externally

  • How can I externally set a private member inside a strategy?

    class strategy(bt.Strategy):
      def __init__(self):
        self.title = "how to set this externally?"
    cerebro.addstrategy(strategy) # using strategy
    cerebro.strategy.setTitle("new title")

  • administrators

    Strategy instances are created during backtesting execution and not before.. What you need is to pass a parameter with your desired title.

  • Cool works for me, thanks.

    class firstStrategy(bt.Strategy):
        params = (
       x= self.params.period
    cerebro.addstrategy(firstStrategy, period=14)

Log in to reply