Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    array assignment index out of range

    General Code/Help
    3
    3
    584
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mohamad Rafiee
      Mohamad Rafiee last edited by

      from future import (absolute_import, division, print_function,
      unicode_literals)

      import datetime # For datetime objects
      import os.path # To manage paths
      import sys # To find out the script name (in argv[0])

      Import the backtrader platform

      import backtrader as bt
      import backtrader.indicators as btind
      import math

      Create a Stratey

      class TestStrategy(bt.Strategy):
      params = (
      ('maperiod', 15),
      )

      def log(self, txt, dt=None):
          ''' Logging function fot this strategy'''
          dt = dt or self.datas[0].datetime.date(0)
          print('%s, %s' % (dt.isoformat(), txt))
      
      def __init__(self):
          # Keep a reference to the "close" line in the data[0] dataseries
          self.dataclose = self.datas[0].close
      
          # To keep track of pending orders and buy price/commission
          self.order = None
          self.buyprice = None
          self.buycomm = None
      
          # Add a MovingAverageSimple indicator
          self.sma = bt.ind.SMA(self.datasclose, period = 40)
      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        Please check the following similar posts (probably you may have the same problem):

        https://community.backtrader.com/topic/407/indexerror-array-assignment-index-out-of-range
        https://community.backtrader.com/topic/1797/getting-indexerror-array-assignment-index-out-of-range-in-cerebro-run

        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          You may want to share the full script.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }