title: How to create Traingular moving average in python using for loop
body: <p>I use python pandas to caculate the following formula
  (<a href="https://i.stack.imgur.com/XIKBz.png" rel="nofollow noreferrer">https://i.stack.imgur.com/XIKBz.png</a>)
  I do it in python like this :</p>
  
  <pre><code>EURUSD['SMA2']= EURUSD['Close']. rolling (2).mean()
  EURUSD['TMA2']= ( EURUSD['Close'] + EURUSD[SMA2']) / 2
  </code></pre>
  
  <p>The proplem is long coding when i calculated TMA 100 , so i need to use " for loop " to easy change TMA period .
  Thanks in advance</p>
  
  <p>Edited :
  I had found the code but there is an error :</p>
  
  <p>values = [] </p>
  
  <p>for i in range(1,201): values.append(eurusd['Close']).rolling(window=i).mean() values.mean() </p>