The UziChan2 strategy is a backtesting trading strategy implemented as a Python class. It inherits from the IStrategy class. The strategy is designed to populate indicators, determine buy signals, and determine sell signals based on the given market data.
The populate_indicators method calculates several indicators using the input dataframe, such as percentage change, exponential moving average, normalized percentage, upper band, lower band, and accumulation/distribution oscillator.
It returns the updated dataframe with the calculated indicators.
The populate_buy_trend method populates the 'buy' column in the dataframe based on certain conditions. It sets the 'buy' value to 1 when the close price or open price is below the lower band, and the accumulation/distribution oscillator is greater than its previous value. The populate_sell_trend method populates the 'sell' column in the dataframe based on certain conditions. It sets the 'sell' value to 1 when the high price is above the upper band, and the accumulation/distribution oscillator is greater than its previous value. The UziChanTB2 class is a subclass of UziChan2 and overrides the populate_indicators method. It calls the parent method and then performs additional operations related to trailing buy and sell orders. The populate_indicators method in UziChanTB2 first calls the parent method to calculate indicators. Then, it calls the trailing_buy and trailing_sell methods to perform trailing buy and sell operations based on the provided pair. Finally, it returns the updated dataframe. The strategy also includes methods such as confirm_trade_entry and confirm_trade_exit to confirm trade entries and exits based on trailing buy and sell orders. These methods check various conditions and return a boolean value indicating whether the trade should be executed. Overall, the strategy calculates indicators, identifies buy and sell signals based on specific conditions, and includes trailing buy and sell functionality for managing trades.