diff --git a/pandas_ta/utils.py b/pandas_ta/utils.py index 9035018..485abf7 100644 --- a/pandas_ta/utils.py +++ b/pandas_ta/utils.py @@ -108,6 +108,46 @@ def cross(series_a:pd.Series, series_b:pd.Series, above:bool =True, asint:bool = return cross +def generate_signal_indicators(indicator, xa, xb, cross_values, xserie, xserie_a, xserie_b, cross_series, offset): + signalsdf = pd.DataFrame() + if xa is not None and isinstance(xa, (int, float)): + if cross_values: + crossed_above = cross_value(indicator, xa, above=True, offset=offset) + else: + crossed_above = above_value(indicator, xa, offset=offset) + signalsdf[crossed_above.name] = crossed_above + + if xb is not None and isinstance(xb, (int, float)): + if cross_values: + crossed_below = cross_value(indicator, xb, above=True, offset=offset) + else: + crossed_below = below_value(indicator, xb, offset=offset) + signalsdf[crossed_below.name] = crossed_below + + # xseries is the default value for both xserie_a and xserie_b + if xserie_a is None: + xserie_a = xserie + if xserie_b is None: + xserie_b = xserie + + if xserie_a is not None and verify_series(xserie_a): + if cross_series: + cross_serie_above = cross(indicator, xserie_a, above=True, offset=offset) + else: + cross_serie_above = above(indicator, xserie_a, offset=offset) + + signalsdf[cross_serie_above.name] = cross_serie_above + + if xserie_b is not None and verify_series(xserie_b): + if cross_series: + cross_serie_below = cross(indicator, xserie_b, above=False, offset=offset) + else: + cross_serie_below = below(indicator, xserie_b, offset=offset) + + signalsdf[cross_serie_below.name] = cross_serie_below + + return signalsdf + def df_error_analysis(dfA:pd.DataFrame, dfB:pd.DataFrame, **kwargs): """ """ col = kwargs.pop('col', None)