The UziChan2 strategy is a trading strategy that uses various indicators to generate buy and sell signals. Here is a breakdown of its key components:
populate_indicators: This method calculates and adds several indicators to the input dataframe, including percentage change (perc), exponential moving average of perc (avg3_perc), normalized perc values (perc_norm), upper channel middle (uc_mid), upper channel standard deviation (uc_stdv), upper channel lower band (uc_low), upper channel upper band (uc_up), and accumulation/distribution oscillator (co). populate_buy_trend: This method populates the buy column of the dataframe with a value of 1 under certain conditions.
It checks if the closing price or opening price is below the upper channel lower band (uc_low), and if the accumulation/distribution oscillator (co) is greater than its previous value.
populate_sell_trend: This method populates the sell column of the dataframe with a value of 1 under certain conditions.
It checks if the high price is above the upper channel upper band (uc_up) and if the accumulation/distribution oscillator (co) is greater than its previous value. The UziChanTB2 class extends the UziChan2 class and overrides the populate_indicators method to add trailing buy and sell functionality. It calls the parent populate_indicators method and then sets up trailing buy and sell orders based on the current price and certain conditions. The strategy uses these indicators and buy/sell signals to make trading decisions during backtesting.