MagicTradeBot 精确配置指南 — 微调技术信号与交易精度

概述

MagicTradeBot 的 精准配置(Precision Configuration) 系统让你能够完全控制信号质量与数量之间的平衡。15+ 种信号类型中的每一种,都在 tradesettings.yaml 文件中拥有独立的配置部分,让你可以将参数从激进模式(高频率、更多噪音)调整到保守模式(低频率、高置信度)。这种精细化控制使你能够扫描数千个交易品种,并筛选出最符合你风险偏好的高质量机会。

质量 vs 数量 权衡

信号严格度光谱

激进模式 ←――――――――――――――――――――――――――――――――――→ 保守模式
(数量多)                                           (质量高)

更多信号                                             更少信号
较低胜率                                             较高胜率
较高风险                                             较低风险
主动交易                                             选择性交易

关键原则: 阈值越严格 = 信号越少但成功概率更高。阈值越宽松 = 信号越多但误报也越多。

配置理念

每个信号参数都可以从以下三个维度进行调整:

  1. 灵敏度 – 信号触发的容易程度(阈值)
  2. 确认度 – 需要多少条件同时满足(多因子确认)
  3. 过滤 – 必须满足哪些附加条件(成交量、波动率等)

配置结构

所有信号设置均集中在 tradesettings.yaml 文件中:

yaml
signals:
  rsi:
    enabled: true
    oversold_threshold: 30
    overbought_threshold: 70
    # ... 更多 RSI 设置

  macd:
    enabled: true
    fast_period: 12
    slow_period: 26
    # ... 更多 MACD 设置

  # ... 所有其他信号设置

每个部分都是 独立可配置的,这使你可以为某些信号采用激进设置,同时为其他信号使用保守设置。


各类信号的配置选项

RSI 信号配置

用途: 控制超买/超卖灵敏度以及背离检测

yaml
rsi:
  enabled: true
  period: 14

  # 阈值配置
  oversold_threshold: 30
  overbought_threshold: 70

  # 质量过滤
  require_volume_confirmation: true
  min_volume_multiplier: 1.5

  # 背离设置
  enable_divergence_detection: true
  divergence_lookback: 20
  divergence_min_strength: 0.6

  # 信号过滤
  ignore_in_strong_trends: true
  min_price_move_percent: 0.5

调优指南:

  • 更多信号: oversold=40, overbought=60, require_volume=false
  • 更高质量信号: oversold=20, overbought=80, require_volume=true, min_strength=0.8

MACD 信号配置

用途: 精细化控制金叉/死叉灵敏度及柱状图阈值

yaml
macd:
  enabled: true

  # 周期设置
  fast_period: 12
  slow_period: 26
  signal_period: 9

  # 信号触发条件
  trigger_on_crossover: true
  trigger_on_histogram_flip: true
  trigger_on_divergence: true

  # 质量过滤
  min_histogram_value: 0.0001
  require_momentum_confirmation: true
  min_bars_since_last_signal: 5

  # 背离设置
  divergence_lookback: 15
  divergence_min_strength: 0.65

  # 市场环境过滤
  ignore_choppy_markets: true
  choppiness_threshold: 61.8

调优指南:

  • 更多信号: fast=8, slow=17, min_histogram=0, ignore_choppy=false
  • 更高质量信号: fast=16, slow=35, min_histogram=0.0005, min_bars=10

布林带配置

目的:控制波动率敏感度和均值回归严格性

yaml
bollinger_bands:
  enabled: true

  period: 20
  std_dev: 2.0

  trigger_on_touch: true
  trigger_on_break: false
  require_reversal_candle: true

  min_band_width_percent: 2.0
  max_band_width_percent: 10.0
  require_volume_spike: true
  min_volume_ratio: 1.3

  enable_squeeze_alerts: true
  squeeze_threshold: 1.5
  squeeze_breakout_multiplier: 2.0

  require_price_return_to_middle: false

调优指南:

  • 更多信号: std_dev=1.5, trigger_on_break=true, require_reversal=false
  • 更优信号: std_dev=2.5, min_band_width=3.0, require_volume=true

ATR信号配置

目的:定义波动率扩张阈值和突破条件

yaml
atr:
  enabled: true
  period: 14

  breakout_multiplier: 1.5
  min_atr_expansion_percent: 20
  lookback_for_expansion: 10

  require_volume_confirmation: true
  min_volume_multiplier: 1.8
  require_directional_close: true
  close_position_percent: 0.8

  min_bars_in_consolidation: 5
  max_prior_volatility: 2.5

  ignore_gaps: true
  ignore_news_hours: true

调优指南:

  • 更多信号: multiplier=1.2, min_expansion=10, min_bars=3
  • 更优信号: multiplier=2.0, min_expansion=30, min_bars=8, volume=2.0x

成交量信号配置

目的:设置异常成交量检测的阈值

yaml
volume:
  enabled: true

  lookback_period: 20
  spike_multiplier: 2.0

  detect_buying_volume: true
  detect_selling_volume: true
  detect_climax_volume: true

  min_candle_body_percent: 40
  require_price_confirmation: true
  min_price_move_percent: 1.0

  climax_multiplier: 4.0
  climax_lookback: 50
  signal_reversal_after_climax: true

  use_volume_profile: true
  significant_level_volume_ratio: 1.5

  ignore_low_liquidity_symbols: true
  min_dollar_volume: 100000

调优指南:

  • 更多信号: multiplier=1.5, min_body=30, min_move=0.5
  • 更优信号: multiplier=3.0, min_body=60, climax=5.0, dollar_volume=500k

动量 / 速度信号配置

目的:检测变化率的加速度

yaml
momentum_velocity:
  enabled: true

  momentum_period: 10
  velocity_lookback: 5

  min_momentum_percent: 2.0
  min_velocity_increase: 1.5

  require_sustained_momentum: true
  min_consecutive_periods: 3
  require_volume_increase: true

  enable_momentum_divergence: true
  divergence_lookback: 15
  divergence_sensitivity: 0.7

  ignore_choppy_conditions: true
  max_directional_changes: 2
  require_trend_alignment: true
  trend_timeframe_multiplier: 4

调优指南:

  • 更多信号: period=5, min_momentum=1.0, consecutive=2, require_trend=false
  • 更优信号: period=20, min_momentum=3.0, consecutive=5, velocity=2.0

RSI背离配置

目的:微调背离敏感度

yaml
rsi_divergence:
  enabled: true

  lookback_period: 20

  min_pivot_strength: 3
  min_pivots_required: 2

  min_divergence_angle: 15
  min_rsi_difference: 5
  min_price_difference_percent: 1.0

  require_volume_confirmation: true
  volume_must_decrease: true
  require_trend_context: true

  detect_hidden_divergence: true
  hidden_requires_stricter_rules: true

  ignore_in_consolidation: true
  min_atr_for_signal: 0.5

调优指南:

  • 更多信号: lookback=10, pivot=2, angle=10, volume=false
  • 更优信号: lookback=30, pivot=5, angle=25, rsi_diff=8

VWAP及波段配置

目的:配置VWAP偏差波段逻辑

yaml
vwap:
  enabled: true

  reset_period: "daily"
  use_cumulative: true

  enable_bands: true
  band_1_std_dev: 1.0
  band_2_std_dev: 2.0
  band_3_std_dev: 3.0

  trigger_on_band_touch: true
  trigger_level: 2
  require_rejection_candle: true

  min_distance_from_vwap_percent: 0.5
  require_volume_at_level: true
  volume_percentile_threshold: 70

  require_return_toward_vwap: true
  min_reversion_percent: 30
  max_bars_for_reversion: 5

  ignore_trending_markets: false
  min_time_from_reset: 60

调优指南:

  • 更多信号: trigger_level=1, min_distance=0.2, rejection=false
  • 更优信号: trigger_level=3, min_distance=1.0, volume_percentile=80

CVD(累计成交量差)配置

目的:检测压力失衡

yaml
cvd:
  enabled: true

  lookback_period: 100

  enable_divergence_signals: true
  divergence_lookback: 20
  min_divergence_strength: 0.7

  cvd_trend_period: 20
  min_cvd_trend_strength: 0.6

  trigger_on_divergence: true
  trigger_on_trend_change: true
  trigger_on_exhaustion: true

  min_cvd_change_percent: 10
  require_price_confirmation: true
  min_price_move_percent: 0.8

  exhaustion_lookback: 10
  exhaustion_threshold: 0.3
  require_volume_divergence: true

  ignore_low_volume_periods: true
  min_volume_for_valid_cvd: 1.5

调优指南:

  • 更多信号: lookback=50, min_change=5, exhaustion=0.5
  • 更优信号: lookback=200, min_change=20, strength=0.8, volume_divergence=true

多时间框架对齐配置

目的:定义跨多个图表区间的对齐规则

yaml
multi_timeframe:
  enabled: true

  base_timeframe: "5m"
  higher_timeframes:
    - "15m"
    - "1h"
    - "4h"

  require_all_aligned: false
  min_alignment_percent: 75

  primary_signals:
    - "RSI"
    - "MACD"
    - "MOMENTUM"

  confirmation_signals:
    - "TREND_DIRECTION"
    - "REGIME"

  trend_indicator: "EMA"
  trend_periods:
    fast: 20
    slow: 50

  require_higher_tf_trend: true
  min_higher_tf_strength: 0.6
  ignore_conflicting_signals: true

  weight_by_timeframe: true
  timeframe_weights:
    "5m": 1.0
    "15m": 1.5
    "1h": 2.0
    "4h": 3.0

调优指南:

  • 更多信号: alignment=50, require_higher_tf_trend=false, check 2 TF
  • 更优信号: alignment=100, require_all=true, check 4+ TF

市场状态检测配置

目的:检测趋势、区间、波动或平稳市场状态

yaml
market_regime:
  enabled: true

  lookback_period: 50

  trend_indicator: "ADX"
  trend_threshold: 25

  range_indicator: "CHOPPINESS"
  range_threshold: 61.8

  volatility_measure: "ATR_PERCENTILE"
  high_volatility_threshold: 70
  low_volatility_threshold: 30

  signal_on_regime_change: true
  require_confirmation_bars: 3

  adjust_other_signals: true

  regime_adjustments:
    trending:
      rsi_overbought: 80
      rsi_oversold: 20
      follow_trend_only: true
    
    ranging:
      bb_std_dev: 1.5
      enable_mean_reversion: true
      disable_breakout_signals: true
    
    volatile:
      atr_multiplier: 2.5
      reduce_position_size: 0.5
    
    calm:
      atr_multiplier: 1.2
      increase_position_size: 1.2

调优指南:

  • 更多信号: lookback=20, trend_threshold=20, confirm=1
  • 更优信号: lookback=100, trend_threshold=30, confirm=5

相对强弱指数 (Relative Strength) 对 BTC 配置

目的: 配置比较指标和超越阈值

相对强弱指数 (Relative Strength) 对 BTC 配置

目的: 配置比较指标和超越阈值

relative_strength:
  enabled: true
  
  # RS 计算
  lookback_period: 20            # 计算 20 个周期的 RS
                                 # 短期 = 10, 长期 = 50
  
  comparison_symbol: "BTCUSDT"   # 默认比较资产
  
  # 强度阈值
  min_outperformance_percent: 5  # 必须超越 ≥5%
                                 # 激进 = 2, 保守 = 10
  
  min_consecutive_periods: 3     # 连续 3 个柱超越
  
  # 质量过滤
  require_volume_confirmation: true
  min_relative_volume: 1.2       # 资产成交量 > BTC 相对成交量 1.2 倍
  
  require_absolute_gain: true    # 资产和 BTC 均为正 (牛市)
  allow_absolute_loss_outperformance: false # 若两者下跌,不发信号
  
  # 背离检测
  detect_rs_divergence: true     # 价格下跌但 RS 上升
  divergence_lookback: 15
  
  # 趋势一致性
  require_btc_trend_agreement: false # 允许与 BTC 相反信号
  btc_trend_threshold: 0.5       # 若需要,BTC 趋势强度阈值
  
  # 突破检测
  detect_rs_breakout: true       # RS 突破前高
  rs_breakout_lookback: 50
  rs_breakout_buffer: 0.95       # 必须超过回溯高点的 95%

调优指南:

  • 更多信号: min_outperformance=2, consecutive=2, require_absolute=false
  • 更优信号: min_outperformance=10, consecutive=5, require_volume=true

订单流失衡 (OFI) 配置

目的: 设置订单簿失衡检测的敏感度

order_flow_imbalance:
  enabled: true
  
  # OFI 计算
  calculation_window: 5          # 在 5 个 tick/柱中测量失衡
                                 # 超快 = 3, 标准 = 5, 慢 = 10
  
  # 失衡阈值
  min_imbalance_ratio: 2.0       # 买卖比例 > 2.0 或 < 0.5
                                 # 激进 = 1.5, 保守 = 3.0
  
  min_imbalance_volume: 10000    # 有效 OFI 信号的最小成交量
  
  # 质量过滤
  require_sustained_imbalance: true
  min_sustained_periods: 3       # 失衡必须持续 3 个计算窗口
  
  require_price_confirmation: true
  min_price_move_with_ofi: 0.1   # 价格必须沿 OFI 方向移动 ≥0.1%
  
  # 失效检测
  detect_ofi_exhaustion: true    # OFI 弱化 = 反转
  exhaustion_ratio_threshold: 1.2 # 失衡低于 1.2
  
  # 上下文过滤
  ignore_low_liquidity: true
  min_order_book_depth: 50000    # 要求最佳买卖价深度 ≥5 万美元
  
  ignore_spread_widening: true   # 当价差过宽时跳过信号
  max_spread_multiplier: 2.0
  
  # 时间过滤
  ignore_market_open_close: true # 跳过开盘/收盘前后 5 分钟
  open_close_buffer_minutes: 5

调优指南:

  • 更多信号: window=3, ratio=1.5, sustained=2, price_move=0.05
  • 更优信号: window=10, ratio=3.0, sustained=5, depth=100k

波动指数 (Choppiness Index) 配置

目的: 定义趋势市场与震荡市场的阈值

choppiness_index:
  enabled: true
  
  # 波动计算
  period: 14                     # 标准 = 14, 快速 = 7, 慢 = 21
  
  # 市场类型阈值
  choppy_threshold: 61.8         # 波动 > 61.8 = 震荡/区间
  trending_threshold: 38.2       # 波动 < 38.2 = 强趋势
                                 # 激进: 55/45, 保守: 65/35
  
  # 信号生成
  signal_on_transition: true     # 越过阈值时发信号
  require_confirmation_bars: 2   # 越过后等待 2 根柱确认
  
  signal_direction_from:         # 买卖方向判定方法
    method: "PRICE_MOMENTUM"     # 选项: "PRICE_MOMENTUM", "BREAKOUT_DIRECTION", "CUSTOM"
    lookback: 10
  
  # 质量过滤
  min_time_in_chop: 10           # 发出突破信号前至少震荡 10 根柱
  max_time_in_chop: 50           # 震荡 >50 根柱时不发信号
  
  require_volume_expansion: true # 突破时成交量必须增加
  min_volume_multiplier: 1.5
  
  # 综合使用
  use_as_filter_only: false      # True = 仅作为其他信号过滤器
  
  filter_other_signals_in_chop: true # 震荡时禁用某些信号
  signals_to_disable_in_chop:
    - "BREAKOUT"
    - "MOMENTUM"
    - "TREND_FOLLOWING"
  
  signals_to_enable_in_chop:
    - "MEAN_REVERSION"
    - "RANGE_TRADING"

调优指南:

  • 更多信号: thresholds=55/45, confirmation=1, min_time=5
  • 更优信号: thresholds=65/35, confirmation=3, min_time=15, max_time=30

Ichimoku 云图配置

目的: 配置 Ichimoku 组件及信号严格度

ichimoku:
  enabled: true
  
  # Ichimoku 周期
  tenkan_period: 9               # 转换线(快)
  kijun_period: 26               # 基准线(中)
  senkou_b_period: 52            # 先行 B 线(慢)
  displacement: 26               # 云前移周期
  
  # 传统: 9/26/52, 激进: 7/22/44, 保守: 12/30/60
  
  # 信号要求
  require_price_above_cloud: true      # 买入信号
  require_price_below_cloud: true      # 卖出信号
  require_tk_cross: true               # Tenkan/Kijun 交叉
  require_positive_chikou: true        # Chikou 在价格上方
  require_future_cloud_agreement: true # 未来云颜色与信号一致
  
  # 严格度等级
  strictness: "moderate"         # 选项: "loose", "moderate", "strict", "extreme"
  
  # 严格度定义:
  # loose: 1 条件
  # moderate: 3 条件
  # strict: 4 条件
  # extreme: 所有 5 条件
  
  # 质量过滤
  min_cloud_thickness_percent: 0.5 # 云厚度 ≥0.5%
  ignore_thin_clouds: true
  
  min_distance_from_cloud: 0.3   # 价格距离云 ≥0.3%
  
  require_volume_confirmation: true
  min_volume_on_signal: 1.3
  
  # 趋势强度
  measure_trend_strength: true
  min_trend_strength: 0.6        # 所有组件一致性 ≥0.6
  
  # 上下文过滤
  ignore_conflicting_components: true # 组件冲突时跳过
  max_conflicting_components: 1

调优指南:

  • 更多信号: periods=7/22/44, strictness="loose", require_only_2_conditions
  • 更优信号: periods=12/30/60, strictness="extreme", min_strength=0.8

组合信号配置

目的: 配置加权多指标共识系统

combined_signals:
  enabled: true
  
  # 信号加权
  weights:
    rsi: 15
    macd: 20
    bollinger_bands: 15
    atr: 10
    volume: 25
    momentum: 10
    divergence: 20
    vwap: 15
    cvd: 20
    # ... 其他信号
  
  # 共识要求
  min_total_weight: 65           # 总加权分 ≥65/100
                                 # 激进 = 45, 保守 = 80
  
  min_signals_agreeing: 3        # 至少 3 个信号一致
                                 # 激进 = 2, 保守 = 5
  
  max_conflicting_signals: 1     # 最大允许 1 个相反信号
  
  # 信号类别
  require_trend_signal: true
  require_momentum_signal: true
  require_volume_signal: true
  
  # 质量增强
  bonus_for_diverggence: 15
  bonus_for_mtf_alignment: 20
  bonus_for_regime_match: 10
  
  # 动态权重调整
  adjust_weights_by_regime: true
  regime_weight_modifiers:
    trending:
      macd: 1.5
      momentum: 1.5
      rsi: 0.7
    ranging:
      rsi: 1.5
      bollinger_bands: 1.5
      macd: 0.6
  
  # 信心评分
  output_confidence_score: true
  min_confidence_for_action: 70
  
  # 超时规则
  max_time_between_signals: 10
  signals_must_be_recent: true

调优指南:

  • 更多信号: min_weight=45, min_signals=2, max_conflicting=2
  • 更优信号: min_weight=80, min_signals=5, max_conflicting=0, min_confidence=80

价格尖峰检测配置

目的: 定义极端价格变动的阈值

spike_detection:
  enabled: true
  
  # 统计阈值
  lookback_period: 100
  std_dev_multiplier: 3.0
  
  # 尖峰类型
  detect_pump_spikes: true
  detect_crash_spikes: true
  
  # 质量过滤
  min_spike_percent: 2.0
  max_spike_percent: 50.0
  
  require_volume_confirmation: true
  min_volume_multiplier: 2.5
  
  require_single_candle: false
  max_candles_for_spike: 3
  
  # 上下文验证
  ignore_gap_spikes: true
  ignore_low_liquidity: true
  min_liquidity_threshold: 50000
  
  # 信号逻辑
  signal_direction:
    pump_action: "BUY"
    crash_action: "SELL"
  
  # 持续 vs 反转
  check_for_continuation: true
  continuation_lookback: 5
  min_continuation_percent: 50
  
  # 失效检测
  detect_spike_exhaustion: true
  exhaustion_volume_multiplier: 5.0
  signal_reversal_on_exhaustion: true

调优指南:

  • 更多信号: std_dev=2.0, min_spike=1.0, volume=1.5x, max_candles=5
  • 更优信号: std_dev=4.0, min_spike=3.0, volume=3.0x, single_candle=true

PUMP / CRASH 信号配置

目的: 配置持续波动检测及成交量确认

pump_crash:
  enabled: true
  
  # 价格变动检测
  min_percent_move: 3.0
  max_bars_for_move: 5
  
  # 成交量要求
  require_volume_surge: true
  min_volume_multiplier: 1.8
  volume_must_increase: true
  
  # 动量验证
  require_momentum_acceleration: true
  min_acceleration_ratio: 1.2
  
  allow_pullback_bars: 1
  max_pullback_percent: 30
  
  # 质量过滤
  require_directional_close: true
  min_close_position: 0.75
  
  ignore_wick_dominated: true
  max_wick_to_body_ratio: 0.6
  
  # 上下文过滤
  ignore_during_news: true
  ignore_market_open: true
  open_buffer_minutes: 15
  
  ignore_low_liquidity: true
  min_dollar_volume: 250000
  
  # 信号类型
  pump_action: "BUY"
  crash_action: "SELL"
  
  # 持续设置
  wait_for_consolidation: false
  consolidation_max_bars: 5
  consolidation_max_range: 1.0
  
  # 失效检测
  detect_climax: true
  climax_volume_multiplier: 4.0
  fade_climax_bars: true

调优指南:

  • 更多信号: min_move=1.5, max_bars=10, volume=1.3x, allow_pullback=2
  • 更优信号: min_move=5.0, max_bars=3, volume=2.5x, acceleration=1.5

总结

MagicTradeBot 的精准配置系统提供了 前所未有的信号质量与数量控制。 通过调整 tradesettings.yaml 中的参数,您可以:

  • 筛选数千个交易品种,仅保留高概率交易机会
  • 匹配您的风险偏好,通过精细严格度控制
  • 适应市场环境,动态调整阈值
  • 优化您的交易风格,从短线到波段交易
  • 智能组合信号,使用加权共识算法
  • 最大化胜率,同时保持合理交易频率

系统可从初学者的简单预设配置扩展到高级算法交易者的全自定义多维过滤。 每个参数均有文档、可回测,帮助您在抓住机会与避免假信号之间找到完美平衡。

📎 Related Topics