Capstone Project Model Solution Tecnical indicator Error

Set parameter values for ATR indicator

atr_period = 27 * 14
atr_multiplier = 3

Calculate the supertrend indicator values

aapl_combined = Supertrend(aapl_combined, atr_period, atr_multiplier)
aapl_combined.tail(5)


KeyError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pandas\core\series.py in setitem(self, key, value)
1084 try:
→ 1085 self._set_with_engine(key, value)
1086 except (KeyError, ValueError):

~\Anaconda3\lib\site-packages\pandas\core\series.py in _set_with_engine(self, key, value)
1145 def _set_with_engine(self, key, value) → None:
→ 1146 loc = self.index.get_loc(key)
1147

~\Anaconda3\lib\site-packages\pandas\core\indexes\datetimes.py in get_loc(self, key, method, tolerance)
675 # unrecognized type
→ 676 raise KeyError(key)
677

KeyError: 442

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
C:\Users\DURDU~1.OZK\AppData\Local\Temp/ipykernel_3684/3195545108.py in
4
5 # Calculate the supertrend indicator values
----> 6 aapl_combined = Supertrend(aapl_combined, atr_period, atr_multiplier)
7 aapl_combined.tail(5)

C:\Users\DURDU~1.OZK\AppData\Local\Temp/ipykernel_3684/247159317.py in Supertrend(df, atr_period, multiplier)
20 # If the current close price crosses above upperband
21 if df.close[curr] > df.final_upperband[prev]:
—> 22 df.supertrend[curr] = True
23 # If the current close price crosses below lowerband
24 elif df.close[curr] < df.final_lowerband[prev]:

~\Anaconda3\lib\site-packages\pandas\core\series.py in setitem(self, key, value)
1099 )
1100 # this is equivalent to self._values[key] = value
→ 1101 self._mgr.setitem_inplace(key, value)
1102 else:
1103 # GH#12862 adding a new key to the Series

~\Anaconda3\lib\site-packages\pandas\core\internals\base.py in setitem_inplace(self, indexer, value)
186 # Note: checking for ndarray instead of np.dtype means we exclude
187 # dt64/td64, which do their own validation.
→ 188 value = np_can_hold_element(arr.dtype, value)
189
190 arr[indexer] = value

~\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py in np_can_hold_element(dtype, element)
2272 if lib.is_integer(element) or lib.is_float(element):
2273 return element
→ 2274 raise ValueError
2275
2276 elif dtype.kind == “c”:

ValueError:

Hi Durdu,
I ran the Solution Notebook from Section 33, Unit 5 of the Technical Indicators Strategies in Python course, and it executed without any errors. Did you encounter this issue only in this specific cell, or were there errors in earlier cells of the notebook as well? Also, could you confirm that we’re referring to the same course section and notebook? Just want to make sure we’re looking at the right one.