# source: https://raw.githubusercontent.com/remiotore/freqtrade/44beaeb6a420cd8e9f2e4ea93e11d6cfa192ee03/strategies/Discord_MA.py
# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from pandas import DataFrame
from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter,
                                IStrategy, IntParameter)

# --------------------------------
# Add your lib to import here
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
# --------------------------------


class Github_remiotore_freqtrade__Discord_MA__20260111_210550(IStrategy):

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # adjust based on market conditions. We would recommend to keep it low for quick turn arounds
    # This attribute will be overridden if the config file contains "minimal_roi"
    minimal_roi = {
        "0": 0.15,    
        "20160": 0.15
    }
    
    #can_short = True

    # Optimal stoploss designed for the strategy
    stoploss = -0.025
    trailing_stop = True

    # Optimal timeframe for the strategy
    timeframe = '1h'

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['ema8'] = ta.EGithub_remiotore_freqtrade__Discord_MA__20260111_210550(dataframe, timeperiod=8)
        dataframe['ema21'] = ta.EGithub_remiotore_freqtrade__Discord_MA__20260111_210550(dataframe, timeperiod=21)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
             (qtpylib.crossed_above(dataframe['ema8'], dataframe['ema21']))
            ),
            'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
            (qtpylib.crossed_below(dataframe['ema8'], dataframe['ema21']))
            ),
            'exit_long'] = 1
        return dataframe