# source: https://raw.githubusercontent.com/waleedba19/trading-bot-live/f7eef7897ed63f7c33203aa06a4725d7a8e3c42b/user_data/strategies/BtcEma200Hold.py
# directory_url: https://github.com/waleedba19/trading-bot-live/blob/main/user_data/strategies/
# User: waleedba19
# Repository: trading-bot-live
# --------------------import talib.abstract as ta

from freqtrade.strategy import IStrategy


class Github_waleedba19_trading_bot_live__BtcEma200Hold__20261026_210640(IStrategy):
    INTERFACE_VERSION = 3

    timeframe = "1d"
    can_short = False

    startup_candle_count = 250
    process_only_new_candles = True

    stoploss = -0.08
    trailing_stop = False
    minimal_roi = {"0": 100}

    def populate_indicators(self, dataframe, metadata):
        dataframe["ema200"] = ta.EMA(dataframe, timeperiod=200)
        return dataframe

    def populate_entry_trend(self, dataframe, metadata):
        dataframe.loc[
            (dataframe["close"] > dataframe["ema200"]) & (dataframe["volume"] > 0),
            "enter_long",
        ] = 1
        return dataframe

    def populate_exit_trend(self, dataframe, metadata):
        dataframe.loc[
            dataframe["close"] < dataframe["ema200"],
            "exit_long",
        ] = 1
        return dataframe
