(self)
| 98 | n2 = 20 |
| 99 | |
| 100 | def init(self): |
| 101 | # Precompute the two moving averages |
| 102 | self.sma1 = self.I(SMA, self.data.Close, self.n1) |
| 103 | self.sma2 = self.I(SMA, self.data.Close, self.n2) |
| 104 | |
| 105 | def next(self): |
| 106 | # If sma1 crosses above sma2, close any existing |