Skip to content

Commit

Permalink
Merge pull request #45 from joshyattridge/Fix_iloc_issue_in_retracements
Browse files Browse the repository at this point in the history
Refactor smc.py to use iloc instead of indexing for high and low values
  • Loading branch information
joshyattridge committed May 25, 2024
2 parents df24ffb + a32b838 commit f79f9d3
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 @@ -848,9 +848,9 @@ def sessions(
and (start_time <= current_time or current_time <= end_time)
):
active[i] = 1
high[i] = max(ohlc["high"][i], high[i - 1] if i > 0 else 0)
high[i] = max(ohlc["high"].iloc[i], high[i - 1] if i > 0 else 0)
low[i] = min(
ohlc["low"][i],
ohlc["low"].iloc[i],
low[i - 1] if i > 0 and low[i - 1] != 0 else float("inf"),
)

Expand Down Expand Up @@ -897,7 +897,7 @@ def retracements(cls, ohlc: DataFrame, swing_highs_lows: DataFrame) -> Series:

if direction[i - 1] == 1:
current_retracement[i] = round(
100 - (((ohlc["low"][i] - bottom) / (top - bottom)) * 100), 1
100 - (((ohlc["low"].iloc[i] - bottom) / (top - bottom)) * 100), 1
)
deepest_retracement[i] = max(
(
Expand All @@ -909,7 +909,7 @@ def retracements(cls, ohlc: DataFrame, swing_highs_lows: DataFrame) -> Series:
)
if direction[i] == -1:
current_retracement[i] = round(
100 - ((ohlc["high"][i] - top) / (bottom - top)) * 100, 1
100 - ((ohlc["high"].iloc[i] - top) / (bottom - top)) * 100, 1
)
deepest_retracement[i] = max(
(
Expand Down

0 comments on commit f79f9d3

Please sign in to comment.