智能追踪止损策略(Intelligent Trailing Stop Loss Strategy)是一个根据价格变化自动调整止损点的策略。它结合了 SAR 指标的逻辑,当价格达到新的高点或低点时,追踪调整止损线,实现最大回撤控制。
该策略的核心逻辑是根据 SAR 指标自动调整止损线。具体来说,它定义了 4 个变量:
在上涨趋势时,止损线会不断上调,追踪价格上涨;当价格转为下跌,止损线保持不变,直到再次转为上涨趋势。
止损线调整的幅度通过步长因子 AF 控制。AF 会在成功设置新的止损点时增加,从而扩大下一步的调整幅度。
该策略最大的优势是可以根据市场波动智能调整止损点,在保证足够的盈利空间的同时,也可以尽量减小最大回撤。相比传统的静态止损方法,它可以更好地捕捉价格趋势。
具体来说,主要有以下几个优势:
该策略也存在一些风险需要注意:
该策略还可以从以下几个方向进行优化:
智能追踪止损策略通过模拟 SAR 指标的运行逻辑,实时调整止损线位置,在保护利润的同时,尽量减少漏失机会的可能。它最大限度发挥了止损这个功能本身的价值。
相比传统固定止损点的策略,该策略可以更好地适应市场的变化,更灵活。通过自定义参数设置,用户可以根据自己的风险偏好选择适合自己的止损模式。
当然,该策略也存在一定的参数优化空间,及结合其他指标可以实现的提高效果。总体来说,它为投资者在止损和止盈之间找到了更加智能的平衡点。
/*backtest
start: 2024-01-17 00:00:00
end: 2024-01-24 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Lucid SAR Strategy", shorttitle="Lucid SAR Strategy", overlay=true)
// Full credit to Sawcruhteez, Lucid Investment Strategies LLC and Casey Bowman.
// This is a strategy version of the Lucid SAR indicator created by the above-mentioned parties.
// Original version of the indicator: https://www.tradingview.com/script/OkACQQgL-Lucid-SAR/
// Branded under the name "Lucid SAR"
// As agreed to with Lucid Investment Strategies LLC on July 9, 2019
// https://lucidinvestmentstrategies.com/
// Created by Casey Bowman on July 4, 2019
// MIT License
// Copyright (c) 2019 Casey Bowman
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
AF_initial = input(0.02)
AF_increment = input(0.02)
AF_maximum = input(0.2)
// start with uptrend
uptrend = true
newtrend = false
EP = high
SAR = low
AF = AF_initial
if not na(uptrend[1]) and not na(newtrend[1])
if uptrend[1]
EP := max(high, EP[1])
else
EP := min(low, EP[1])
if newtrend[1]
AF := AF_initial
else
if EP != EP[1]
AF := min(AF_maximum, AF[1] + AF_increment)
else
AF := AF[1]
SAR := SAR[1] + AF * (EP - SAR[1])
if uptrend[1]
if newtrend
SAR := max(high, EP[1])
EP := min(low, low[1])
else
SAR := min(SAR, low[1])
if not na(low[2])
SAR := min(SAR, low[2])
if SAR > low
uptrend := false
newtrend := true
SAR := max(high, EP[1])
EP := min(low, low[1])
else
uptrend := true
newtrend := false
else
if newtrend
SAR := min(low, EP[1])
EP := max(high, high[1])
else
SAR := max(SAR, high[1])
if not na(high[2])
SAR := max(SAR, high[2])
if SAR < high
uptrend := true
newtrend := true
SAR := min(low, EP[1])
EP := max(high, high[1])
else
uptrend := false
newtrend := false
plot(SAR, color = color.blue, style = plot.style_cross, linewidth = 2)
if (uptrend)
strategy.entry("PBSARLE", strategy.long, comment="PBSARLE")
if (newtrend)
strategy.entry("PBSARSE", strategy.short, comment="PBSARSE")