# source: https://raw.githubusercontent.com/Kblack0610/freqtrade_trading_attempt/3805b8988fd5ce4c69106ed5aff5d93c36064cc4/lab/tests/fixtures/strategies/PlantedLookahead.py
# directory_url: https://github.com/Kblack0610/freqtrade_trading_attempt/blob/master/lab/tests/fixtures/strategies/
# User: Kblack0610
# Repository: freqtrade_trading_attempt
# --------------------"""A deliberately broken strategy: it buys on the next candle's close. lab/analyze.py must flag it."""

from pandas import DataFrame

from freqtrade.strategy import IStrategy


class Github_Kblack0610_freqtrade_trading_attempt__PlantedLookahead__20261105_060239(IStrategy):
    timeframe = "5m"
    minimal_roi = {"0": 0.01}
    stoploss = -0.05
    startup_candle_count = 20

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe["next_close"] = dataframe["close"].shift(-1)
        dataframe["sma"] = dataframe["close"].rolling(20).mean()
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[dataframe["next_close"] > dataframe["close"] * 1.002, "enter_long"] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[dataframe["close"] < dataframe["sma"], "exit_long"] = 1
        return dataframe
