SMAOffsetProtectOptV1 Strategy Deep Analysis
Strategy ID: #361 (361st of 465 strategies)
Strategy Type: EMA Offset + EWO Protection + RSI Filter
Timeframe: 5 minutes (5m)
I. Strategy Overview
SMAOffsetProtectOptV1 is a quantitative trading strategy based on EMA offset strategy, identifying buy and sell opportunities through price deviation from moving averages, using Elliott Wave Oscillator (EWO) as a protection mechanism combined with RSI to filter false signals. The "Protect" in the strategy name emphasizes its multi-layer protection mechanism, while "OptV1" indicates optimization version 1.
Core Features
| Feature | Description |
|---|---|
| Buy Conditions | 2 independent buy signals, flexible switching |
| Sell Conditions | 1 base sell signal + ROI table take-profit + trailing stop |
| Protection Mechanism | EWO trend protection + RSI overbought filter |
| Timeframe | Main timeframe 5m + informative timeframe 1h |
| Dependencies | talib, numpy, pandas, technical, qtpylib |
II. Strategy Configuration Analysis
2.1 Basic Risk Parameters
# ROI exit table
minimal_roi = {
"0": 0.01 # Exit immediately when 1% profit is reached
}
# Stop loss setting
stoploss = -0.10 # 10% fixed stop loss
# Trailing stop
trailing_stop = True
trailing_stop_positive = 0.001 # Positive trailing threshold 0.1%
trailing_stop_positive_offset = 0.01 # Offset 1%
trailing_only_offset_is_reached = True # Only enable trailing after offset is reached
Design Rationale:
- ROI is set to immediate 1%, combined with
ignore_roi_if_buy_signal=True, the strategy ignores ROI when a buy signal exists, allowing profits to run - Trailing stop is set aggressively (0.1%) to quickly lock in profits
- 10% fixed stop loss provides a larger margin for error
2.2 Order Type Configuration
use_sell_signal = True
sell_profit_only = True
sell_profit_offset = 0.01
ignore_roi_if_buy_signal = True
Key Settings:
sell_profit_only=True: Only respond to sell signals when profitableignore_roi_if_buy_signal=True: Core differentiated setting, ignores ROI limits when buy signals exist, allowing the strategy to continue holding
III. Buy Conditions Detailed Analysis
3.1 Protection Mechanisms (2 Groups)
The "Protect" in the strategy name is embodied in the EWO (Elliott Wave Oscillator) protection mechanism:
| Protection Type | Parameter Description | Default Value |
|---|---|---|
| EWO High Threshold | Considers uptrend pullback when EWO > ewo_high | 5.638 |
| EWO Low Threshold | Considers deep oversold when EWO < ewo_low | -19.993 |
| RSI Filter | RSI < rsi_buy prevents chasing highs | 61 |
EWO Calculation:
def EWO(dataframe, ema_length=5, ema2_length=35):
ema1 = ta.EMA(df, timeperiod=ema_length)
ema2 = ta.EMA(df, timeperiod=ema2_length)
emadif = (ema1 - ema2) / df['close'] * 100
return emadif
The strategy uses custom EWO parameters: fast_ewo=50, slow_ewo=200 (note these are special parameters defined within the strategy, different from the calculation function's defaults).
3.2 Typical Buy Condition Examples
Condition #1: Trend Pullback Buy
# Logic
- price < EMA(base_nb_candles_buy) * low_offset # Price below offset moving average
- EWO > ewo_high # Uptrend confirmed
- RSI < rsi_buy # Not overbought
- volume > 0 # Has volume
Interpretation: This is a "trend pullback buy" strategy. When price pulls back below the moving average by a certain percentage (low offset), while EWO shows an uptrend (> 5.638), and RSI is not overheated (< 61), it's considered a good buying opportunity.
Condition #2: Deep Oversold Buy
# Logic
- price < EMA(base_nb_candles_buy) * low_offset # Price below offset moving average
- EWO < ewo_low # Deep oversold
- volume > 0 # Has volume
Interpretation: This is an "oversold bounce" strategy. When price is below the offset moving average, while EWO shows extreme oversold (< -19.993), RSI is not considered, and it's a direct buy for a bounce play.
3.3 Two Buy Conditions Classification
| Condition Group | Condition Number | Core Logic |
|---|---|---|
| Trend Pullback | Condition #1 | EWO high threshold + RSI filter, catching pullback opportunities in uptrend |
| Oversold Bounce | Condition #2 | EWO low threshold, catching bounce opportunities after extreme oversold |
IV. Sell Logic Detailed Analysis
4.1 Single-Layer Take-Profit System
The strategy employs a single ROI threshold + trailing stop mechanism:
Profit Range Threshold Signal Name
─────────────────────────────────────────────
Immediate 1% minimal_roi
Trailing Stop 0.1% trailing_stop_positive
4.2 Special Sell Scenarios
| Scenario | Trigger Condition | Signal Name |
|---|---|---|
| MA Deviation Sell | close > EMA(base_nb_candles_sell) * high_offset | Sell signal |
| Profit Protection | Profit > 1% + buy signal exists | Ignore ROI |
Core Design: ignore_roi_if_buy_signal=True is the unique design of this strategy. When buy signals still exist in the market, even if the 1% ROI threshold is reached, the strategy will continue to hold, letting profits run.
4.3 Base Sell Signal (1)
# Sell signal 1: MA deviation sell
- close > EMA(base_nb_candles_sell) * high_offset # Price above offset moving average
- volume > 0 # Has volume
Default Parameter Values:
base_nb_candles_sell = 49(EMA period)high_offset = 1.006(high offset coefficient)
Interpretation: Triggers sell signal when price rises above the 49-period EMA by 0.6%.
V. Technical Indicator System
5.1 Core Indicators
| Indicator Category | Specific Indicator | Purpose |
|---|---|---|
| Trend Indicator | EMA (Exponential Moving Average) | Dynamic support/resistance |
| Oscillator | EWO (Elliott Wave Oscillator) | Trend strength and overbought/oversold judgment |
| Momentum Indicator | RSI (Relative Strength Index) | Overbought filter |
| Volume | volume | Validity confirmation |
5.2 Informative Timeframe Indicators (1h)
The strategy uses 1 hour as the information layer, providing higher-dimension trend judgment:
- Defines 1h timeframe for all trading pairs in
informative_pairs - Supports cross-timeframe analysis (though not deeply used in current code)
5.3 Optimizable Parameters
The strategy uses Freqtrade's hyperparameter optimization framework, defining the following optimizable parameters:
| Parameter Type | Parameter Name | Range | Default Value | Optimization Space |
|---|---|---|---|---|
| IntParameter | base_nb_candles_buy | 5-80 | 16 | buy |
| IntParameter | base_nb_candles_sell | 5-80 | 49 | sell |
| DecimalParameter | low_offset | 0.9-0.99 | 0.978 | buy |
| DecimalParameter | high_offset | 0.99-1.1 | 1.006 | sell |
| DecimalParameter | ewo_high | 2.0-12.0 | 5.638 | buy |
| DecimalParameter | ewo_low | -20.0--8.0 | -19.993 | buy |
| IntParameter | rsi_buy | 30-70 | 61 | buy |
VI. Risk Management Features
6.1 Multi-Layer Stop Loss Protection
The strategy employs a three-layer stop loss mechanism:
- Fixed Stop Loss: -10% hard stop loss, preventing extreme losses
- Trailing Stop: Enabled after 1% profit with 0.1% trailing, quickly locking in profits
- Signal Stop Loss: Exit when sell signal triggers
6.2 Buy Signal Protection
The design philosophy of ignore_roi_if_buy_signal=True:
- Avoid exiting too early in strong trends
- Allow winning positions more room to run
- Only exit when trend reverses (sell signal)
6.3 RSI Filter Mechanism
The RSI < 61 condition prevents buying in the following situations:
- Chasing highs after significant price increases
- Risky positions with short-term overheating
VII. Strategy Advantages and Limitations
✅ Advantages
- Strong Parameter Optimizability: 7 optimizable parameters, adaptable to different market environments
- Dual Buy Logic: Catches both trend pullbacks and oversold bounces
- Profit Protection Mechanism:
ignore_roi_if_buy_signalallows winning positions to run more fully - Clean and Efficient Code: Clear logic, moderate computational load
⚠️ Limitations
- Single Timeframe Decision: Though 1h information layer exists, actual decisions are mainly based on 5m
- Ranging Market Risk: EMA offset strategies are prone to frequent stop losses in sideways markets
- No Volatility Filter: No ATR or other volatility indicators used, may misjudge during high volatility
VIII. Applicable Scenario Recommendations
| Market Environment | Recommended Configuration | Description |
|---|---|---|
| Uptrend | Default parameters | EWO high threshold condition works well for pullbacks |
| Ranging Market | Increase low_offset | Reduce buy frequency, avoid false signals |
| Downtrend | Enable ewo_low condition | Oversold bounce strategy can catch short-term opportunities |
| High Volatility Period | Adjust trailing_stop | Increase trailing stop offset to avoid premature exits |
IX. Applicable Market Environment Details
SMAOffsetProtectOptV1 belongs to the EMA Offset Strategy Series, a classic strategy type validated by the community. Based on its code architecture and logic design, it is most suitable for markets with clear trends, while performance is limited during severe fluctuations or one-sided plunges.
9.1 Strategy Core Logic
- MA Offset: Using price deviation from moving average to identify overbought/oversold
- EWO Protection: Judging trend strength through the difference between fast/slow EMAs
- RSI Filter: Preventing chasing highs in overbought areas
9.2 Performance in Different Market Environments
| Market Type | Performance Rating | Analysis |
|---|---|---|
| 📈 Slow Bull Trend | ⭐⭐⭐⭐⭐ | EMA offset + trailing stop work perfectly, catching pullback opportunities |
| 🔄 Mild Fluctuation | ⭐⭐⭐☆☆ | Offset parameters can be tuned to adapt, but false signal risk remains |
| 📉 One-sided Decline | ⭐⭐☆☆☆ | ewo_low condition can catch bounces, but higher risk |
| ⚡ Severe Volatility | ⭐☆☆☆☆ | EMA lag causes signal delay, trailing stop frequently triggered |
9.3 Key Configuration Recommendations
| Configuration Item | Recommended Value | Description |
|---|---|---|
| base_nb_candles_buy | 16-20 | Shorter period suitable for 5m timeframe |
| low_offset | 0.97-0.98 | Control buy threshold |
| ewo_high | 4.0-6.0 | Uptrend confirmation threshold |
| trailing_stop_positive | 0.001-0.005 | Adjust according to volatility |
X. Important Reminder: The Cost of Complexity
10.1 Learning Cost
Although the strategy code is simple, understanding EWO indicator and MA offset logic requires some quantitative foundation. It's recommended to first understand the following concepts:
- EMA (Exponential Moving Average) calculation and meaning
- Elliott Wave Oscillator principle
- Trailing stop working mechanism
10.2 Hardware Requirements
| Number of Trading Pairs | Minimum Memory | Recommended Memory |
|---|---|---|
| 1-10 pairs | 2GB | 4GB |
| 10-50 pairs | 4GB | 8GB |
| 50+ pairs | 8GB | 16GB |
10.3 Difference Between Backtesting and Live Trading
EMA offset strategies are prone to overfitting in backtesting because:
- EMA period parameters can perfectly match historical data
- Offset coefficients can be precisely adjusted to optimal
- In live trading, market structure changes can cause parameters to become ineffective
10.4 Manual Trader Recommendations
If you want to manually apply this strategy's logic:
- Use 16-period EMA as dynamic support line
- Watch when price is about 2.2% below EMA
- Confirm EWO is positive (trend up)
- Consider entering when RSI is below 61
- Consider exiting when price returns to 0.6% above EMA
XI. Summary
SMAOffsetProtectOptV1 is a clearly structured, logically explicit EMA offset strategy. Its core value lies in:
- Dual Buy Logic: Covers both trend pullbacks and oversold bounces
- EWO Protection Mechanism: Confirming trend direction through Elliott Wave Oscillator
- Flexible Profit Management:
ignore_roi_if_buy_signalallows winning positions to run more fully
For quantitative traders, this is a suitable strategy for beginners to learn, with clean code, optimizable parameters, and clear logic. However, be careful to avoid overfitting historical data, and conduct sufficient forward testing before live trading.