Skip to main content

Dyna_opti Strategy: In-Depth Analysis

Strategy Number: #152 (152nd of 465 strategies)
Strategy Type: Bollinger Band Mean Reversion + Dynamic Take-Profit/Stoploss
Timeframe: 5 Minutes (5m) + 1 Hour Informational Layer


I. Strategy Overview​

Dyna_opti is a highly parameterized complex strategy developed by @werkkrew. It combines multiple technical indicators (Bollinger Bands, RMI, ATR, SSL Channel, etc.) and implements dynamic take-profit and custom stoploss mechanisms.

Key Characteristics​

FeatureDescription
Buy Conditions1 main buy condition + informational layer protection
Sell ConditionsDynamic ROI + custom stoploss
Protection2 sets of buy protection parameters (informational layer filtering)
Timeframe5 minutes (main) + 1 hour (informational layer)
DependenciesTA-Lib, technical, numpy

II. Strategy Configuration Analysis​

2.1 Basic Risk Parameters​

# ROI Exit Table
minimal_roi = {
"0": 0.18724, # Immediate exit: 18.72% profit
"20": 0.04751, # After 20 minutes: 4.75% profit
"30": 0.02393, # After 30 minutes: 2.39% profit
"72": 0 # After 72 minutes: break-even exit
}

# Stoploss Settings
stoploss = -0.28819 # -28.82% hard stoploss

# Dynamic ROI Configuration
use_dynamic_roi = True
droi_trend_type = 'any' # Any of RMI/SSL/Candle trend
droi_pullback = False # Whether pullback follows ROI table
droi_pullback_amount = 0.015 # Pullback threshold

2.2 Custom Stoploss Configuration​

use_custom_stoploss = True
cstp_threshold = -0.05 # Activates when profit < -5%
cstp_bail_how = 'time' # Time / ROC / any method
cstp_bail_time = 961 # Force exit after 961 minutes
cstp_bail_roc = -0.018 # Exit when ROC < -1.8%

III. Entry Conditions Details​

3.1 Informational Layer Protection Mechanism​

The strategy uses the 1-hour timeframe as an informational layer with two layers of protection:

# Upper boundary protection
if inf_guard == 'upper' or 'both':
conditions.append(
close <= 3d_low + inf_pct_adr_top * adr
)

# Lower boundary protection
if inf_guard == 'lower' or 'both':
conditions.append(
close >= 3d_low + inf_pct_adr_bot * adr
)

3.2 Core Buy Condition (BinHV45 Strategy)​

# Bollinger Band breakout buy
conditions.append(
bb_lowerband.shift() > 0 & # Previous candle has lower band
bbdelta > close * bbdelta_close & # Bollinger band width sufficient
closedelta > close * closedelta_close & # Close price change sufficient
tail < bbdelta * tail_bbdelta & # Lower wick short
close < bb_lowerband.shift() & # Close price breaks below lower band
close <= close.shift() # Close not above previous candle
)

IV. Exit Conditions Details​

4.1 Dynamic ROI System​

The strategy uses min_roi_reached_dynamic for dynamic take-profit:

Trend TypeTrigger ConditionROI Value
RMI TrendRMI rising count >= 3100% (no exit)
SSL TrendSSL channel upward100% (no exit)
Candle Trend3+ consecutive bullish candles100% (no exit)

4.2 Custom Stoploss Logic​

def custom_stoploss(...):
if current_profit < cstp_threshold: # Profit < -5%
if cstp_bail_how == 'time': # Time-based
if trade_dur > cstp_bail_time: # Exceeds 961 minutes
return 0.001 # Force exit
if cstp_bail_how == 'roc': # ROC-based
if sroc <= cstp_bail_roc: # ROC < -1.8%
return 0.001

V. Technical Indicator System​

5.1 Core Indicators​

CategoryIndicatorParametersPurpose
VolatilityBollinger Bands12 period, 2x std devPrice boundaries
MomentumRMI24/21/8 periodsMomentum judgment
TrendSSL-ATR21 periodTrend direction
VolatilityATR24 periodVolatility
MomentumSROC21/13/21 periodsRate of change

5.2 Custom Indicators​

  • MA Streak: Number of consecutive bullish/bearish candles
  • Percent Change Channel (PCC): Percentage change channel
  • Momentum Pinball: ROC-based RSI

VI. Risk Management Features​

6.1 Multi-Layer Protection Mechanism​

  1. Informational layer protection: 1-hour timeframe ADR protection
  2. Dynamic ROI: Adjusts take-profit based on trend strength
  3. Custom stoploss: Dual protection based on time and momentum
  4. Generous hard stoploss: -28.82% allows ample volatility room

6.2 Trend Judgment​

The strategy uses three trend judgment methods:

  • RMI momentum indicator
  • SSL channel direction
  • Candle consecutive rise/fall

VII. Strategy Pros & Cons​

✅ Pros​

  1. Highly parameterized: Every parameter is optimizable
  2. Dynamic take-profit: Adjusts exit strategy based on trend strength
  3. Multi-layer protection: Informational layer + trend judgment + take-profit/stoploss
  4. Rich indicators: Integration of more than ten technical indicators

⚠️ Cons​

  1. Extremely complex: Code exceeds 1000 lines
  2. Many parameters: Prone to overfitting
  3. High computational load: Demanding on hardware

VIII. Applicable Scenarios​

Market EnvironmentRecommended ConfigNotes
Trending marketsEnable dynamic ROILet profits run during trends
High volatilityKeep defaultGenerous stoploss suits high volatility
Oscillating marketLower ROI thresholdsReduce trend protection

IX. Applicable Market Environments in Detail​

9.1 Core Strategy Logic​

  • Bollinger Band breakout: Buy when price breaks below the lower band
  • Trend protection: Use RMI/SSL to judge trends
  • Dynamic exit: Let profits run when trend continues, exit promptly when trend reverses

9.2 Performance in Different Market Environments​

Market TypeRatingAnalysis
📈 Trending up★★★★★Dynamic ROI lets profits run
🔄 Wide-range oscillation★★★★☆Bollinger band breakout effective in ranges
📉 One-way down★★☆☆☆Trend protection may fail
⚡️ Extreme consolidation★★★☆☆Complex calculation, mediocre effect

X. Important Notes: The Cost of Complexity​

10.1 Learning Curve​

The strategy code exceeds 1000 lines with extensive custom functions and complex logic. It is recommended to first understand the core indicator principles.

10.2 Hardware Requirements​

The strategy has a massive computational load:

Number of PairsMin RAMRecommended RAM
20-40 pairs2GB4GB
40-80 pairs4GB8GB

XI. Summary​

Dyna_opti is a highly complex advanced strategy suitable for experienced quantitative traders. Its core value lies in:

  1. Dynamic take-profit: Intelligently adjusts exits based on trend strength
  2. Multi-layer protection: Informational layer + trend judgment + take-profit/stoploss
  3. Highly customizable: Every parameter is optimizable

Recommendation: Use only after fully understanding the strategy logic. Prevent overfitting.