Skip to main content

DevilStra Strategy: In-Depth Analysis

1. Strategy Overview

DevilStra (Devil Strategy) is a highly creative quantitative trading strategy created by @Mablue (Masoud Azizi). The strategy's naming derives from its unique design philosophy — channeling the "devil's" wisdom through combining and permuting existing technical indicators into powerful trading rules.

The strategy's philosophy, revealed in a poetic header:

"The devil is always stronger than God. But only God can create new life. The devil creates powerful spells through small creatures (like frogs, etc.), through fragmentation and mixing them."

This reveals DevilStra's core philosophy: Not seeking to invent new technical indicators (that's "God's" work), but constructing powerful trading rules through clever combination, fragmentation, and reorganization of existing indicators.

1.1 Core Innovations

  1. Modular Design: Buy and sell logic encapsulated as independent "Spells"
  2. Genetic Algorithm Thinking: Hyperopt automatically selects optimal spell combinations for each trading pair
  3. Indicator Fragmentation: Over 150 technical indicators disaggregated, recombined, and cross-used
  4. Dynamic Allocation: Each trading pair uses different spell sequences, enabling differentiated trading

2. Architecture Analysis

2.1 SPELLS Dictionary

SPELLS is the strategy's core data structure containing 9 base spells:

SpellPronunciationCategory
Zi/ziː/Purple Power - Spell 1
Gu/ɡuː/Ancient Wisdom - Spell 2
Lu/luː/Path of Light - Spell 3
La/lɑː/Moon's Blessing - Spell 4
Si/siː/Secret Guardian - Spell 5
Pa/pɑː/Source of Power - Spell 6
De/deɪ/Divine Decision - Spell 7
Ra/rɑː/Sun's Power - Spell 8
Cu/kuː/Mystic Guardian - Spell 9

Each spell contains buy_params and sell_params — three sets of indicator combinations each.

2.2 gene_calculator Function

gene_calculator dynamically computes technical indicators based on string identifiers:

def gene_calculator(dataframe, indicator):
# Format: indicator_name-param1-param2-param3-param4
# Supports 1-5 segment indicator definitions

3. Operator System

DevilStra defines 16 operators across four categories:

Basic Comparison: >, <, = Numeric Comparison: >R, <R, =R Crossover Operators: C (any crossover), CA (cross above), CB (cross below) Ratio Operators: />R, /<R, /=R Trend Operators: UT (uptrend), DT (downtrend), OT (oscillation) Crossover Trend Operators: CUT (crossover rising), CDT (crossover falling), COT (crossover oscillation)


4. Entry Logic

4.1 Entry Flow

Pair enters → Get index in whitelist

Extract corresponding spell from buy_spell

Parse spell's buy parameters

Generate three independent conditions

All conditions AND-combined

If met → Trigger buy signal

4.2 Zi Spell Buy Conditions Example

  1. Condition 1: MINUS_DI-50 / BOP-4 > 0.1763 (ratio exceeds threshold)
  2. Condition 2: HT_TRENDMODE-50 crosses above MACD-0-50 (trend momentum crossover)
  3. Condition 3: CORREL-128 crosses below and continues below DEMA-52 (correlation indicator weakening)

5. Exit Logic and Risk Management

5.1 Exit Flow

Symmetric to entry — each pair has its own sell spell:

Pair enters → Get index in whitelist

Extract corresponding spell from sell_spell

Parse spell's sell parameters

Generate three independent conditions

All conditions AND-combined

If met → Trigger sell signal

5.2 ROI and Stoploss Configuration

ROI Table:

Time Threshold (minutes)Target Return
057.4%
1757 (~29 hours)15.8%
3804 (~63 hours)8.9%
6585 (~110 hours)0%

Stoploss: -28% (allows significant drawdown)


6. Hyperopt Optimization Mechanism

6.1 Optimization Target

The strategy uses SharpeHyperOptLoss as the optimization objective:

freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy sell -s DevilStra

6.2 Example Optimization Results

16/16: 108 trades. 75/18/15 Wins/Draws/Losses.
Avg profit 7.77%. Median profit 8.89%.
Total profit 0.08404983 BTC (84.05Σ%).
Objective: -11.22849

Key metrics:

  • Win rate: 75/108 ≈ 69.4%
  • Average profit: 7.77%
  • Total profit: 84.05%

7. Pros & Cons

Advantages

  1. Highly modular: Spell system easy to maintain and extend
  2. Adaptive: Each pair independently optimized
  3. Rich indicators: 150+ technical indicators comprehensively used
  4. Flexible condition combinations: 16 operators support complex logic

Limitations

  1. Parameter complexity: Large number of parameters requiring optimization
  2. Overfitting risk: Highly customized parameter combinations may lack generalization
  3. Static pairlist requirement: Does not support dynamic pair lists
  4. Black-box characteristic: Trading logic not transparent, difficult to audit

8. Summary

DevilStra represents a unique quantitative trading methodology: combination beats creation — not seeking to invent new indicators, but deeply excavating the combinatorial potential of existing indicators.

Core philosophy: Through indicator fragmentation and combination, create powerful strategies

Key features:

  • 9 base spells, each containing 6 trading conditions
  • 16 operators covering comparison, crossover, and trend judgment
  • Hyperopt automatically optimizes spell combinations
  • Each pair independently optimized via StaticPairList