Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. aman jha
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    aman jha

    @aman jha

    0
    Reputation
    10
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    aman jha Unfollow Follow

    Latest posts made by aman jha

    • RE: AttributeError: module 'backtrader.indicators' has no attribute 'DummyInd'

      @ab_trader Thank you for taking the time to reply.
      But I didn't get what was wrong exactly. I made the change and the error is gone.

      posted in Indicators/Strategies/Analyzers
      aman jha
      aman jha
    • AttributeError: module 'backtrader.indicators' has no attribute 'DummyInd'

      Hi guys, need a little help
      I tested building a custom indicator with the help of the Backtrader documentation and I got an AttributeError. I am new to Backtrader and I'd appreciate a little help.
      Code```

      import backtrader as bt
      import backtrader.indicators as btind
      class DummyInd(bt.Indicator):
          lines = ('dummyline',)
      
          params = (('value', 5),)
      
          def __init__(self):
              self.lines.dummyline = bt.Max(0.0, self.params.value)
      class MyStrategy(bt.Strategy):
          def __init__(self):
              self.rocp = btind.DummyInd()
          def next(self):
              print(self.rocp)
      
      cerebro = bt.Cerebro()  # create a "Cerebro" engine instance
      
      # Create a data feed
      data = bt.feeds.YahooFinanceData(dataname='sunpharma.csv')
      
      cerebro.adddata(data)  # Add the data feed
      
      cerebro.addstrategy(MyStrategy)  # Add the trading strategy
      print('Starting Portfolio Value: ',cerebro.broker.getvalue())
      cerebro.run()  # run it all
      print('Final Portfolio Value: ',cerebro.broker.getvalue())
      cerebro.plot()  # and plot it with a single command
      posted in Indicators/Strategies/Analyzers
      aman jha
      aman jha