Skip to main content

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

FeatureDescription
Buy Conditions2 independent buy signals, flexible switching
Sell Conditions1 base sell signal + ROI table take-profit + trailing stop
Protection MechanismEWO trend protection + RSI overbought filter
TimeframeMain timeframe 5m + informative timeframe 1h
Dependenciestalib, 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 profitable
  • ignore_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 TypeParameter DescriptionDefault Value
EWO High ThresholdConsiders uptrend pullback when EWO > ewo_high5.638
EWO Low ThresholdConsiders deep oversold when EWO < ewo_low-19.993
RSI FilterRSI < rsi_buy prevents chasing highs61

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 GroupCondition NumberCore Logic
Trend PullbackCondition #1EWO high threshold + RSI filter, catching pullback opportunities in uptrend
Oversold BounceCondition #2EWO 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

ScenarioTrigger ConditionSignal Name
MA Deviation Sellclose > EMA(base_nb_candles_sell) * high_offsetSell signal
Profit ProtectionProfit > 1% + buy signal existsIgnore 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 CategorySpecific IndicatorPurpose
Trend IndicatorEMA (Exponential Moving Average)Dynamic support/resistance
OscillatorEWO (Elliott Wave Oscillator)Trend strength and overbought/oversold judgment
Momentum IndicatorRSI (Relative Strength Index)Overbought filter
VolumevolumeValidity 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 TypeParameter NameRangeDefault ValueOptimization Space
IntParameterbase_nb_candles_buy5-8016buy
IntParameterbase_nb_candles_sell5-8049sell
DecimalParameterlow_offset0.9-0.990.978buy
DecimalParameterhigh_offset0.99-1.11.006sell
DecimalParameterewo_high2.0-12.05.638buy
DecimalParameterewo_low-20.0--8.0-19.993buy
IntParameterrsi_buy30-7061buy

VI. Risk Management Features

6.1 Multi-Layer Stop Loss Protection

The strategy employs a three-layer stop loss mechanism:

  1. Fixed Stop Loss: -10% hard stop loss, preventing extreme losses
  2. Trailing Stop: Enabled after 1% profit with 0.1% trailing, quickly locking in profits
  3. 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

  1. Strong Parameter Optimizability: 7 optimizable parameters, adaptable to different market environments
  2. Dual Buy Logic: Catches both trend pullbacks and oversold bounces
  3. Profit Protection Mechanism: ignore_roi_if_buy_signal allows winning positions to run more fully
  4. Clean and Efficient Code: Clear logic, moderate computational load

⚠️ Limitations

  1. Single Timeframe Decision: Though 1h information layer exists, actual decisions are mainly based on 5m
  2. Ranging Market Risk: EMA offset strategies are prone to frequent stop losses in sideways markets
  3. No Volatility Filter: No ATR or other volatility indicators used, may misjudge during high volatility

VIII. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
UptrendDefault parametersEWO high threshold condition works well for pullbacks
Ranging MarketIncrease low_offsetReduce buy frequency, avoid false signals
DowntrendEnable ewo_low conditionOversold bounce strategy can catch short-term opportunities
High Volatility PeriodAdjust trailing_stopIncrease 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 TypePerformance RatingAnalysis
📈 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 ItemRecommended ValueDescription
base_nb_candles_buy16-20Shorter period suitable for 5m timeframe
low_offset0.97-0.98Control buy threshold
ewo_high4.0-6.0Uptrend confirmation threshold
trailing_stop_positive0.001-0.005Adjust 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 PairsMinimum MemoryRecommended Memory
1-10 pairs2GB4GB
10-50 pairs4GB8GB
50+ pairs8GB16GB

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:

  1. Use 16-period EMA as dynamic support line
  2. Watch when price is about 2.2% below EMA
  3. Confirm EWO is positive (trend up)
  4. Consider entering when RSI is below 61
  5. 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:

  1. Dual Buy Logic: Covers both trend pullbacks and oversold bounces
  2. EWO Protection Mechanism: Confirming trend direction through Elliott Wave Oscillator
  3. Flexible Profit Management: ignore_roi_if_buy_signal allows 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.