Skip to content

Commit f79f9d3

Browse files
Merge pull request #45 from joshyattridge/Fix_iloc_issue_in_retracements
Refactor smc.py to use iloc instead of indexing for high and low values
2 parents df24ffb + a32b838 commit f79f9d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

smartmoneyconcepts/smc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,9 @@ def sessions(
848848
and (start_time <= current_time or current_time <= end_time)
849849
):
850850
active[i] = 1
851-
high[i] = max(ohlc["high"][i], high[i - 1] if i > 0 else 0)
851+
high[i] = max(ohlc["high"].iloc[i], high[i - 1] if i > 0 else 0)
852852
low[i] = min(
853-
ohlc["low"][i],
853+
ohlc["low"].iloc[i],
854854
low[i - 1] if i > 0 and low[i - 1] != 0 else float("inf"),
855855
)
856856

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

898898
if direction[i - 1] == 1:
899899
current_retracement[i] = round(
900-
100 - (((ohlc["low"][i] - bottom) / (top - bottom)) * 100), 1
900+
100 - (((ohlc["low"].iloc[i] - bottom) / (top - bottom)) * 100), 1
901901
)
902902
deepest_retracement[i] = max(
903903
(
@@ -909,7 +909,7 @@ def retracements(cls, ohlc: DataFrame, swing_highs_lows: DataFrame) -> Series:
909909
)
910910
if direction[i] == -1:
911911
current_retracement[i] = round(
912-
100 - ((ohlc["high"][i] - top) / (bottom - top)) * 100, 1
912+
100 - ((ohlc["high"].iloc[i] - top) / (bottom - top)) * 100, 1
913913
)
914914
deepest_retracement[i] = max(
915915
(

0 commit comments

Comments
 (0)