# source: https://raw.githubusercontent.com/DerSalvador/freqtrade-helm-chart/a669dc11b640b0eb63aa8f8b51e9f181fd7ee43c/chart/deployed_strategies/binance-michael-k8s-namespace/ADX_15M_USDT2.py
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
# --------------------------------

class Github_DerSalvador_freqtrade_helm_chart__ADX_15M_USDT2__20260115_122204(IStrategy):
    INTERFACE_VERSION = 3
    timeframe = '15m'
    # ROI table:
    minimal_roi = {'0': 0.10313, '102': 0.07627, '275': 0.04228, '588': 0}
    # Stoploss:
    stoploss = -0.31941

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
        dataframe['plus_di'] = ta.PLUS_DI(dataframe, timeperiod=25)
        dataframe['minus_di'] = ta.MINUS_DI(dataframe, timeperiod=25)
        dataframe['sar'] = ta.SAR(dataframe)
        dataframe['mom'] = ta.MOM(dataframe, timeperiod=14)
        dataframe['exit-adx'] = ta.ADX(dataframe, timeperiod=14)
        dataframe['exit-plus_di'] = ta.PLUS_DI(dataframe, timeperiod=25)
        dataframe['exit-minus_di'] = ta.MINUS_DI(dataframe, timeperiod=25)
        dataframe['exit-sar'] = ta.SAR(dataframe)
        dataframe['exit-mom'] = ta.MOM(dataframe, timeperiod=14)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        #(dataframe['adx'] > 45) &
        #(dataframe['minus_di'] > 26) &
        # (dataframe['plus_di'] > 33) &
        dataframe.loc[qtpylib.crossed_above(dataframe['minus_di'], dataframe['plus_di']), 'entry'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # (dataframe['minus_di'] > 22) &
        #(dataframe['plus_di'] > 24) &
        dataframe.loc[(dataframe['adx'] > 91) & (dataframe['exit-minus_di'] > 91) & qtpylib.crossed_above(dataframe['exit-plus_di'], dataframe['exit-minus_di']), 'exit'] = 1
        return dataframe