Initial commit of Triple RSI Drop strategy
This commit is contained in:
parent
21cacfaf0c
commit
47abf99dfd
21
strategies/triple_rsi_drop.py
Normal file
21
strategies/triple_rsi_drop.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user