The SMAOffset strategy is a backtesting trading strategy implemented in Python. It uses Simple Moving Average (SMA) and Exponential Moving Average (EMA) indicators to generate buy and sell signals based on certain conditions. The strategy defines several parameters that can be optimized through hyperparameter optimization.
The buy parameters include the number of candles to consider for buying (base_nb_candles_buy), the buy trigger type (buy_trigger), and a low offset value (low_offset).
Similarly, the sell parameters include the number of candles to consider for selling (base_nb_candles_sell), the sell trigger type (sell_trigger), and a high offset value (high_offset).
The strategy also incorporates a stop loss value (stoploss) to limit potential losses. Additionally, it defines a minimal return on investment (ROI) table to set the desired level of profitability. The timeframe for this strategy is set to 5 minutes (timeframe), and it uses custom indicators (ma_offset_buy and ma_offset_sell) calculated based on the selected trigger types and the specified offset values. The populate_indicators function is responsible for calculating the custom indicators. It uses the selected trigger types and the provided number of candles to calculate the moving average indicators (ma_offset_buy and ma_offset_sell) multiplied by the offset values. The populate_buy_trend and populate_sell_trend functions determine the buy and sell signals, respectively. They compare the closing price of the asset with the calculated moving average indicators and volume conditions to generate the respective signals. The strategy can also incorporate a trailing stop feature (trailing_stop) and a custom stop loss function (custom_stoploss), although they are not currently implemented in this version. Overall, the SMAOffset strategy aims to generate buy signals when the closing price of an asset crosses below the calculated moving average indicator with a specific offset, and sell signals when the closing price crosses above the moving average indicator with a different offset.