This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from random import normalvariate | |
| ########################################################################## | |
| # "Real world" that we're trying to track | |
| class RealWorld: | |
| def __init__(self): | |
| self.position = 0.0 | |
| self.velocity = 0.5 | |
| self.time_step = 0.1 | |
| self.time = 0.0 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def avg_true_range(self, df): | |
| ind = range(0,len(df)) | |
| indexlist = list(ind) | |
| df.index = indexlist | |
| for index, row in df.iterrows(): | |
| if index != 0: | |
| tr1 = row["High"] - row["Low"] | |
| tr2 = abs(row["High"] - df.iloc[index-1]["Close"]) | |
| tr3 = abs(row["Low"] - df.iloc[index-1]["Close"]) |