From a32b838163bdb3ec12664cee935852f5e2dd8ec7 Mon Sep 17 00:00:00 2001 From: Joshua Attridge Date: Sun, 26 May 2024 00:13:23 +0100 Subject: [PATCH] Refactor smc.py to use iloc instead of indexing for high and low values --- smartmoneyconcepts/smc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smartmoneyconcepts/smc.py b/smartmoneyconcepts/smc.py index 2433077..9d6e1fb 100644 --- a/smartmoneyconcepts/smc.py +++ b/smartmoneyconcepts/smc.py @@ -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"), ) @@ -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( ( @@ -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( (