The WenRarri strategy is a trading strategy implemented in Python for backtesting purposes. It uses technical indicators such as Bollinger Bands (BB) and Stochastic Oscillator (STOCH) to generate buy and sell signals. Here's a breakdown of how the strategy works:
The strategy calculates Bollinger Bands with a length of 20 and a standard deviation of 2 using the pdta.bbands function.
It also calculates the Stochastic Oscillator with a period of 14 and parameters (3, 3) using the pdta.stoch function.
The strategy populates the following indicators in the input dataframe:
BB_LOWER_20: The lower Bollinger Band value.
BB_MIDDLE_20: The middle Bollinger Band value. BB_UPPER_20: The upper Bollinger Band value. STOCH_k_14_3_3: The %K value of the Stochastic Oscillator. STOCH_d_14_3_3: The %D value of the Stochastic Oscillator. For the buy signal, the strategy checks the following conditions:
The previous candle's closing price is above the lower Bollinger Band. The %K and %D values of the Stochastic Oscillator are below 20. The volume is greater than 0. If all these conditions are met, a "buy" signal of 1 is assigned to the corresponding row in the dataframe. For the sell signal, the strategy checks the following conditions:
The previous candle's closing price is above the upper Bollinger Band. The %K and %D values of the Stochastic Oscillator are above 80. The volume is greater than 0. If all these conditions are met, a "sell" signal of 1 is assigned to the corresponding row in the dataframe. The strategy also sets the following parameters:
stoploss: The stop-loss value is set to -0.1, indicating a 10% stop-loss. trailing_stop: Trailing stop is enabled. trailing_stop_positive: The positive trailing stop value is set to 0.308. trailing_stop_positive_offset: The positive trailing stop offset value is set to 0.314. trailing_only_offset_is_reached: Trailing stop is only activated when the offset is reached. process_only_new_candles: The strategy processes only new candles. use_sell_signal: Sell signals are used. sell_profit_only: Profit is considered for sell signals. ignore_roi_if_buy_signal: ROI is ignored if a buy signal is present. startup_candle_count: The number of candles required for strategy startup is set to 100. Please note that this description is based on the code provided and may not capture all the intricacies or details of the strategy. It's always recommended to thoroughly test and validate any trading strategy before using it with real funds.