# source: https://raw.githubusercontent.com/CharlesLehnen/LightweightCharts-for-Freqtrade/fc7f9233341ced8b17ba783e623697729dd65a96/bots/test_bot/user_data/strategies/RSI.py
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta

class Github_CharlesLehnen_LightweightCharts_for_Freqtrade__RSI__20250730_070451(IStrategy):
    """
    Easiest visualization strategy:
    Buy when RSI < 30, Sell when RSI > 70.
    No stoploss, no ROI, no trailing stop.
    """

    timeframe = '5m'
    stoploss = -0.99                # No stoploss
    minimal_roi = {}            # No ROI

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (dataframe['rsi'] < 30),
            'enter_long'
        ] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (dataframe['rsi'] > 70),
            'exit_long'
        ] = 1
        return dataframe
