Skip to content

Commit

Permalink
fixing iloc in previous_high_low
Browse files Browse the repository at this point in the history
  • Loading branch information
joshyattridge committed May 23, 2024
1 parent 48be4d2 commit 26dd012
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions smartmoneyconcepts/smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ def previous_high_low(cls, ohlc: DataFrame, time_frame: str = "1D") -> Series:
last_broken_time = resampled_ohlc.index[-1]
# remove rows with nan values (ignoring weekends)
resampled_ohlc = resampled_ohlc.dropna()
previous_high[i] = resampled_ohlc["high"][-2] if len(resampled_ohlc) > 1 else np.nan
previous_low[i] = resampled_ohlc["low"][-2] if len(resampled_ohlc) > 1 else np.nan
currently_broken_high = ohlc["high"][i] > previous_high[i] or currently_broken_high
currently_broken_low = ohlc["low"][i] < previous_low[i] or currently_broken_low
previous_high[i] = resampled_ohlc["high"].iloc[-2] if len(resampled_ohlc) > 1 else np.nan
previous_low[i] = resampled_ohlc["low"].iloc[-2] if len(resampled_ohlc) > 1 else np.nan
currently_broken_high = ohlc["high"].iloc[i] > previous_high[i] or currently_broken_high
currently_broken_low = ohlc["low"].iloc[i] < previous_low[i] or currently_broken_low
broken_high[i] = 1 if currently_broken_high else 0
broken_low[i] = 1 if currently_broken_low else 0

Expand Down

0 comments on commit 26dd012

Please sign in to comment.