title: BitCoin Algo not iterating through historical data correctly
body: <p>I'm creating a simple trading backtester on Bitcoin, yet I'm having trouble with the for loops in my code. The current code is based on 2 simple moving averages <code>q</code> and <code>z</code> (currently for learning purposes no real strategy). <code>info</code> is a dataframe holding Bitcoin historical data from a csv file. There seems to be an outofbounce error and I can't figure it out. Any help would be appreciated.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  cash = 10000
  
  file = 'BTC-USD.csv'
  data = pd.read_csv(file)
  
  y = data['Adj Close'][1000:]
  x = data['Date'][1000:]
  v = data['Volume'][1000:]
  h = data['High'][1000:]
  l = data['Low'][1000:]
  
  def movAvg(values,time):
      times=np.repeat(1.0,time)/time
      sma = np.convolve(values,times,'valid')
      return sma
  
  z = movAvg(y,12)
  q  = movAvg(y,9)
  SP = len(x[50-1:])
  
  
  def AlgoCal(account,info):
      #i = 1050
      bought = False
      test = []
      for x in info.index:
          if q[x]&lt;z[x]:
              if bought == False:
                  temp = info[x]
                  account = account-info[x]
                  test.append(account)
                  bought = True
          elif q[x]&gt;z[x]:
              if bought == True:
                  temp = info[x]
                  account = account + info[x]
                  test.append(account)
                  bought = False
          else:
              print("Error")
      return(test)
  
  money = AlgoCal(cash,y)
  print(money)
  </code></pre>
  
  <p>Sample Data from Yahoo Bitcoin csv</p>
  
  <pre><code>Date,Open,High,Low,Close,Adj Close,Volume
  2014-09-17,465.864014,468.174011,452.421997,457.334015,457.334015,21056800
  2014-09-18,456.859985,456.859985,413.104004,424.440002,424.440002,34483200
  ........
  ........
  2020-05-21,9522.740234,9555.242188,8869.930664,9081.761719,9081.761719,39326160532
  2020-05-22,9080.334961,9232.936523,9008.638672,9182.577148,9182.577148,29810773699
  2020-05-23,9185.062500,9302.501953,9118.108398,9209.287109,9209.287109,27727866812
  2020-05-24,9196.930664,9268.914063,9165.896484,9268.914063,9268.914063,27658280960
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "main.py", line 47, in &lt;module&gt;
      money = AlgoCal(cash,y)
    File "main.py", line 31, in AlgoCal
      if q[x]&lt;z[x]:
  IndexError: index 1066 is out of bounds for axis 0 with size 1066
  </code></pre>