Ninja_SMA Strategy: In-Depth Analysis
Strategy ID: #244 (Strategy #244 of 465) Strategy Type: NFI Series - Ninja SMA Mode Timeframe: 15 Minutes (15m)
I. Strategy Overview
Ninja_SMA is the "Ninja" version within the NFI (Nostalgia For Infinity) series, using SMA (Simple Moving Average) as its core analytical tool. The Ninja version represents an agile, fast trading style. While maintaining NFI's multi-condition architecture advantages, signal response speed has been optimized.
SMA is one of the most basic and classic trend indicators in technical analysis, smoothing price fluctuations by calculating the average price over a certain period to reflect market trend direction. Ninja_SMA combines SMA's stability with Ninja's agility, forming a trading system that is both robust and flexible.
Core Characteristics
| Feature | Description |
|---|---|
| Entry Conditions | Multiple SMA-based trend signals |
| Exit Conditions | Multi-layer take-profit + stop-loss protection |
| Protection Mechanisms | SMA trend filtering + dynamic stop-loss |
| Timeframe | 15-minute primary timeframe |
| Dependencies | pandas, numpy, TA-Lib |
II. Strategy Configuration Analysis
2.1 Core Risk Parameters
# ROI Exit Table (Time: Minimum Profit Rate)
minimal_roi = {
"0": 0.10, # Immediate exit: 10% profit
"30": 0.06, # After 30 minutes: 6% profit
"60": 0.035, # After 60 minutes: 3.5% profit
"120": 0.015 # After 120 minutes: 1.5% profit
}
# Stop-Loss Settings
stoploss = -0.10 # -10% hard stop-loss
# Trailing Stop
trailing_stop = True
trailing_stop_positive = 0.03 # 3% trailing activation point
trailing_stop_positive_offset = 0.05 # 5% offset trigger
Design Philosophy:
- Moderate ROI (10%): Balances profit expectation with probability of achievement
- Standard Stop-Loss (-10%): Controllable loss baseline
- Flexible Trailing (3-5%): Protects existing profits
2.2 Order Type Configuration
order_types = {
"entry": "limit",
"exit": "limit",
"stoploss": "limit",
"stoploss_on_exchange": False,
"exit_timeout_count": 0,
}
III. Entry Conditions Details
3.1 SMA Core Mechanism
SMA (Simple Moving Average) calculation method:
SMA = (P1 + P2 + ... + Pn) / n
Where P is the closing price for each period and n is the calculation period.
SMA Characteristics:
- All prices treated equally, equal weighting
- Good smoothing effect, effectively filters noise
- Relatively lagging but highly stable
3.2 Core Entry Conditions
Condition Group 1: Golden Cross
- Short-term SMA crosses above long-term SMA
- Volume expands with confirmation
- Price stands above MAs
Condition Group 2: Price Pullback to SMA
- Price retraces to near SMA and finds support
- SMA slopes upward
- Candlestick shows bounce-back signal
Condition Group 3: SMA Multi-Asset Arrangement
- Short, medium, and long-term SMAs arranged upward in sequence
- Price above all MAs
- Trend clearly upward
3.3 Protection Mechanisms
| Protection Type | Parameters | Function |
|---|---|---|
| Trend Filtering | Price vs. SMA relationship | Only trade with the trend |
| MA Confirmation | Short-term SMA crosses above long-term SMA | Trend strengthening confirmation |
| Support Verification | SMA as dynamic support | Confirm valid support |
| Multi-Period Resonance | Different period SMAs simultaneously met | Improve signal quality |
IV. Exit Logic Details
4.1 Multi-Layer Take-Profit System
Strategy uses a tiered take-profit mechanism:
Profit Rate Zone Threshold Signal Name
─────────────────────────────────────────────
0-30 minutes 10% Quick Profit
30-60 minutes 6% Medium-term Target
60-120 minutes 3.5% Conservative Exit
120+ minutes 1.5% End-of-Session Breakeven
4.2 Special Exit Scenarios
| Scenario | Trigger Condition | Signal Name |
|---|---|---|
| Death Cross | Short-term SMA crosses below long-term SMA | Trend Exit |
| Price Breaks Below SMA | Price breaks below key MA | Support Breakdown |
| High Altitude Pullback | Price deviates far from SMA | Profit-taking |
| Stop-Loss Triggered | Loss exceeds 10% | Hard Stop |
4.3 Basic Exit Signals
# Exit Signal 1: Death Cross
- Short-term SMA crosses below long-term SMA
- Trend weakening
# Exit Signal 2: Breaks Below MA Support
- Price breaks below SMA
- Support becomes resistance
# Exit Signal 3: Stop-Loss Triggered
- Loss reaches -10%
- Protect capital
V. Technical Indicator System
5.1 Core Indicator: SMA
| Indicator | Parameters | Purpose |
|---|---|---|
| Short-Term SMA | 5, 10 | Sensitive short-term price changes |
| Medium-Term SMA | 20, 30 | Confirm medium-term trend direction |
| Long-Term SMA | 50, 100, 200 | Determine long-term trend direction |
5.2 Auxiliary Indicators
| Indicator | Purpose |
|---|---|
| RSI | Momentum verification, overbought/oversold judgment |
| ATR | Volatility measurement, dynamic stop-loss reference |
| Volume | Trend confirmation, price-volume coordination |
5.3 SMA Trading Signal Interpretation
| Signal Type | Condition | Meaning |
|---|---|---|
| Golden Cross | Short SMA crosses above long SMA | Buy signal, trend turns bullish |
| Death Cross | Short SMA crosses below long SMA | Sell signal, trend turns bearish |
| Support | Price retraces to SMA without breaking | Buy opportunity, support valid |
| Multi-Asset Up | SMAs arranged upward in sequence | Strong uptrend, hold positions |
VI. Risk Management Features
6.1 SMA Trend Filtering
SMA, as a trend judgment tool, provides the following protection:
| Filtering Type | Description |
|---|---|
| Trend Trading | Only go long when SMA is upward |
| MA Angle | Only enter when SMA slopes upward |
| Multi-Period Confirmation | Only trade when multiple SMAs resonate |
6.2 Tiered Stop-Loss Mechanism
| Stop-Loss Type | Trigger Condition | Description |
|---|---|---|
| Hard Stop | -10% | Final defense, protect principal |
| Trailing Stop | 3% activation, 5% trigger | Protect existing profits |
| MA Stop | Price breaks below SMA | Trend exit |
6.3 Capital Management Recommendations
| Number of Pairs | Single Position Size | Description |
|---|---|---|
| 5-10 | 10-15% | Moderate diversification |
| 10-20 | 5-10% | Diversify risk |
| 20+ | 3-5% | Maximum diversification |
VII. Strategy Pros & Cons
✅ Pros
- Simple and Intuitive: SMA is the most basic indicator, easy to understand and use
- Computationally Efficient: Low resource consumption, fast response
- Clear Trends: MA direction is clear, signals are not confusing
- Mature and Reliable: Classic method verified by decades of market testing
- Ninja Agility: Optimized response speed while maintaining stability
⚠️ Cons
- Lagging: SMA is a lagging indicator, relatively slow to respond
- Average Ranging Market Performance: Frequent false signals in sideways
- Parameter Sensitive: Different period parameters have significantly different effects
- Requires Trend: Easily beaten up in ranging markets
VIII. Applicable Scenarios
| Market Environment | Recommended Config | Description |
|---|---|---|
| Trending Up | Actively go long | MA multi-asset bullish arrangement |
| Trending Down | Short or stand aside | MA multi-asset bearish arrangement |
| Ranging Market | Reduce trades | Filter false signals |
| Clear Trend | Focus participation | Trend is a friend |
IX. Applicable Market Environment Details
Ninja_SMA is a strategy within the NFI series that combines SMA stability with Ninja agility. Based on its code architecture and market characteristics, it is most suitable for markets with clear trends, while performing average in ranging markets.
9.1 Strategy Core Logic
- SMA Trend Judgment: Use simple moving average to determine major direction
- Trend Trading: Go long when SMA is upward, stand aside when downward
- Ninja Agility: Optimized signal triggering, fast response
- Multi-Condition Confirmation: Filter false signals, improve win rate
9.2 Performance in Different Market Environments
| Market Type | Rating | Analysis |
|---|---|---|
| 📈 Trending Up | ⭐⭐⭐⭐⭐ | MA multi-asset bullish, signals clear, profit by following trend |
| 🔄 Ranging Market | ⭐⭐☆☆☆ | Frequent golden/death crosses, many false signals |
| 📉 Downtrend | ⭐⭐⭐⭐☆ | MA multi-asset bearish, can short or stand aside |
| ⚡️ Extreme Volatility | ⭐⭐⭐☆☆ | Trend clear but volatile, requires caution |
9.3 Key Configuration Recommendations
| Config Item | Recommended Value | Description |
|---|---|---|
| SMA Period | 5, 20, 50 | Classic combination |
| Stop-Loss | -10% | Strict stop-loss |
| Trading Pairs | 5-15 | Moderate diversification |
X. Summary
Ninja_SMA is a strategy within the NFI series that combines SMA stability with Ninja agility. Its core value lies in:
- Simple and Reliable: SMA is the most classic trend indicator, enduring
- Computationally Efficient: Low resource consumption, suitable for long-term operation
- Clear Trends: MA direction is clear, signals are not confusing
- Ninja Optimization: Response speed improved while maintaining stability
For quantitative traders, Ninja_SMA provides a concise, reliable, and easy-to-understand trading system. It is suitable for investors pursuing stable trend trading and is also an introductory choice for learning quantitative trading.