title: Python/Pandas calculate Ichimoku chart components
body: <p>I have Pandas DataFrame object with Date, Open, Close, Low and High daily stock data. I want to calculate components of <a href="https://www.investopedia.com/terms/i/ichimoku-cloud.asp" rel="nofollow noreferrer">Ichimoku</a> chart. I can get my data using the following code:</p>
  <pre><code>high_prices = data['High']
  close_prices = data['Close']
  low_prices = data['Low']
  dates = data['Date']  # contains datetime objects
  </code></pre>
  <p>I need to calculate the following series (Ichimoku calls it Tenkan-Sen line):</p>
  <p><strong>(9-period high + 9-period low) / 2</strong></p>
  <ul>
  <li>9-period high = the highest High value of last 9 days,</li>
  <li>9-period low =  the lowest Low value of last 9 days,
  so both should begin on 9th day.</li>
  </ul>
  <p><img src="https://i.stack.imgur.com/gadZ2.gif" alt="enter image description here" /></p>
  <p>I've found a solution in R language <a href="http://www.r-bloggers.com/ichimoku-clouds-r-code-trading/" rel="nofollow noreferrer">here</a>, but it's difficult for me to translate it to Python/Pandas code.</p>
  <p>Ichimoku chart contains of more components, but when I will know how to count Tenkan-Sen line in Pandas, I will be able to count all of them (I will share the code).</p>