Add script for calculating internal bar strength signals

This commit is contained in:
moshferatu 2024-10-27 06:38:20 -07:00
parent 3fe9b7aa59
commit d887e6e7b3

View 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')