Files
obsidian-vault/05 投资交易/freqtrade策略中的移动止损(Trailing Stop)是如何设置的?.md
2026-06-23 00:24:32 +08:00

91 lines
4.3 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#交易 #量化交易 #策略研究 #freqtrade #DeepSeek
以下是 Freqtrade 策略中追踪止损Trailing Stop相关参数的详细解析结合其功能、配置逻辑及实盘应用说明
---
### 🔍 一、核心参数解析
1. **`trailing_stop = False`**
- **作用**​:是否启用追踪止损功能。
- `True`:开启后,止损位会随盈利增加自动上移(做多)或下移(做空),锁定部分利润[1,4,8](@ref)。
- **当前设置**`False` 表示禁用此功能,止损位固定不变。
- **实盘建议**​:趋势策略中建议启用(`True`),可避免盈利大幅回吐[7](@ref)。
2. **`trailing_stop_positive = 0.01`**
- **作用****盈利达到多少后启动追踪止损**​(示例中为 `0.01` 即 1%[1,4](@ref)。
- **逻辑**
- 若持仓盈利 ≥ 1%,止损位开始动态跟随价格。
- 例如:买入价 $100盈利达 $101 时止损位从 $90 上移至 $100锁定成本
- **注意事项**​:需与 `trailing_stop_positive_offset` 配合使用。
3. **`trailing_stop_positive_offset = 0.0`**
- **作用****启动追踪止损的最低盈利阈值**​(示例中 `0.0` 表示无限制)[1,4](@ref)。
- **常见配置**
- 若设为 `0.05`5%),则需盈利 ≥5% 后才启动追踪止损。
- _当前未配置_表示只要盈利 >0 即启动(可能因市场噪音频繁触发)。
4. **`trailing_only_offset_is_reached = False`**
- **作用**​:是否仅在达到 `trailing_stop_positive_offset` 的盈利阈值后才允许追踪止损[1,4](@ref)。
- `True`:严格按阈值执行,避免小幅波动干扰。
- `False`:无视阈值,盈利 >0 即启动(示例未启用)。
---
### ⚙️ 二、参数协作逻辑(启用追踪止损时)
```
trailing_stop = True # 启用
trailing_stop_positive = 0.03 # 盈利3%后启动
trailing_stop_positive_offset = 0.01 # 盈利需≥1%才允许启动
trailing_only_offset_is_reached = True # 严格依赖阈值
```
**运作流程**
1. 持仓盈利 <1% 固定止损 -8%)。
2. 盈利 1% 启动追踪止损止损位从成本价上移 3%如买入价 $100 止损位 $97)。
3. 价格继续上涨至 $110 止损位同步上移至 $106.7锁定 $3.3 利润[7,8](@ref)
---
### ⚠️ 三、实盘注意事项
1. **适用场景**
- **趋势策略**适合单边行情如突破交易避免过早止盈[7](@ref)
- **震荡策略**频繁触发止损增加交易成本[6](@ref)
2. **参数优化建议**
|**参数**|**保守策略**|**激进策略**|**说明**|
|---|---|---|---|
|`trailing_stop_positive`|0.02 (2%)|0.05 (5%)|盈利达标后启动的步长|
|`trailing_stop_positive_offset`|0.03 (3%)|0.01 (1%)|启动追踪止损的最低盈利要求|
|`trailing_only_offset_is_reached`|True|False|是否严格依赖阈值|
3. **风险控制**
- 避免与固定止损`stoploss = -0.1`冲突二者选其一[4](@ref)
- 回测验证需测试不同市场周期如牛市/熊市下的参数鲁棒性[1](@ref)
---
### 💎 总结
- **核心目的**通过动态调整止损位**保护盈利**实现截断亏损让利润奔跑[7,8](@ref)
- **禁用状态**当前配置`trailing_stop=False`意味着止损位固定不变需依赖其他风控手段如固定止损)。
- **启用建议**
1. 设置 `trailing_stop=True` 并配置偏移量 `trailing_stop_positive_offset=0.03`)。
2. 避免频繁触发确保 `trailing_stop_positive` 步长 > 市场平均波动幅度[6](@ref)。
> 示例配置参考(趋势策略):
>
> ```
> trailing_stop = True
> trailing_stop_positive = 0.04 # 盈利4%后启动追踪
> trailing_stop_positive_offset = 0.02 # 盈利需≥2%
> trailing_only_offset_is_reached = True # 严格依赖阈值
> ```
>
> 此配置要求盈利 ≥2% 后才启动止损位动态上移,每次上移幅度为当前价格的 4%,适合中长线持仓[1,4](@ref)。