diff --git a/strategies/triple_rsi_drop.py b/strategies/triple_rsi_drop.py new file mode 100644 index 0000000..e931fcc --- /dev/null +++ b/strategies/triple_rsi_drop.py @@ -0,0 +1,21 @@ +from numpy import where +from pandas import DataFrame, Series + +from indicators import sma, rsi + +def triple_rsi_drop(data: DataFrame) -> Series: + """ + Generate swing trading signals based on the Triple RSI Drop strategy. + + Returns a Series with 'L' for long signals and 'N' otherwise. + """ + ma_200 = sma(data, period = 200) + rsi_5 = rsi(data, period = 5) + + above_ma_200 = data['Close'] > ma_200 + rsi_below_60_three_days_ago = rsi_5.shift(2) < 60 + rsi_decline_for_three_days = (rsi_5 < rsi_5.shift(1)) & (rsi_5.shift(1) < rsi_5.shift(2)) + rsi_below_30 = rsi_5 < 30 + + conditions = above_ma_200 & rsi_below_60_three_days_ago & rsi_decline_for_three_days & rsi_below_30 + return Series(where(conditions, 'L', 'N'), index = data.index) \ No newline at end of file