Add script for calculating internal bar strength signals
This commit is contained in:
parent
3fe9b7aa59
commit
d887e6e7b3
9
strategies/internal_bar_strength.py
Normal file
9
strategies/internal_bar_strength.py
Normal file
@ -0,0 +1,9 @@
|
||||
from pandas import DataFrame, Series
|
||||
|
||||
def signals(data: DataFrame) -> Series:
|
||||
"""
|
||||
Calculate the Internal Bar Strength (IBS) signal.
|
||||
Returns a Series with 'L' for long signals and 'N' otherwise.
|
||||
"""
|
||||
ibs_series = (data['Close'] - data['Low']) / (data['High'] - data['Low'])
|
||||
return ibs_series.apply(lambda ibs: 'L' if ibs < 0.2 else 'N')
|
Loading…
Reference in New Issue
Block a user