
轨迹追踪指数移动均线策略是一种基于趋势的量化交易策略,它使用不同周期的指数移动均线(EMA)来识别加密货币市场的潜在入市和出市信号。通过追踪不同EMA之间的交叉情况,可以发现回调入市机会和趋势入市机会,以最大限度获得潜在收益,同时控制风险。
该策略使用4条不同周期的EMA,分别是8周期、12周期、24周期和72周期的EMA。它们在图表上发挥指示趋势方向的作用。当收盘价格突破慢线时,表示买入机会。当快线突破慢线时,表示卖出机会。
入市信号 有两种:
1. 回调入市:收盘价格突破12日线、24日线和72日线时,构成回调入市信号。
2. 趋势入市:收盘价格突破72日线,同时8日线突破12日线和24日线时,构成趋势入市信号。
出场信号 有三种:
1. 固定盈利:设定某一固定值作为盈利退出点,如100点。
2. 滑点止损:设定某一固定滑点值,如50点,作为止损线。
3. 转折退出:24日线下穿12日线时,认为趋势发生转折,选择退出。
该策略最大的优势在于能同时抓住回调和趋势两种机会入市。使用快线和慢线组合,避免被短期波动误导判断。EMA还能有效滤除价格异常波动的噪音,捕捉长期趋势。总体来说,该策略具有如下优势:
该策略也存在一些风险需要预防:
针对上述风险,可采取以下措施加以控制:
该策略还有一定优化空间,主要可从以下几个方面入手:
该轨迹追踪EMA策略整体来说是一种趋势跟踪策略。它同时兼顾追涨和回调,通过EMA交叉判定入市时机。可配置性强,使用简单,有效控制风险。随着参数优化和逐步完善,它的表现还具有很大提升空间,值得推荐。
/*backtest
start: 2023-10-31 00:00:00
end: 2023-11-30 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © moondevonyt
//@version=5
strategy("Cornoflower Trend Following Crypto", overlay=true)
// Input Settings
lenEma8 = input(8, title="Length of 8 EMA")
lenEma12 = input(12, title="Length of 12 EMA")
lenEma24 = input(24, title="Length of 24 EMA")
lenEma72 = input(72, title="Length of 72 EMA")
// Calculate the EMAs
ema8 = ta.ema(close, lenEma8)
ema12 = ta.ema(close, lenEma12)
ema24 = ta.ema(close, lenEma24)
ema72 = ta.ema(close, lenEma72)
// Entry Conditions
pullbackEntry = ta.crossover(close, ema12) and ta.crossover(close, ema24) and ta.crossover(close, ema72)
initialEntry = ta.crossover(close, ema72) and ta.crossover(ema8, ema12) and ta.crossover(ema8, ema24)
// Exit Conditions
profitTarget = 100 // Example target in pips, adjust according to your preference
trailingStop = 50 // Example trailing stop value in pips, adjust according to your preference
exitCondition = ta.crossunder(ema12, ema24)
// Execute Strategy
if pullbackEntry
strategy.entry("Pullback Entry", strategy.long)
if initialEntry
strategy.entry("Initial Entry", strategy.long)
if strategy.position_size > 0
strategy.exit("Profit Target", "Pullback Entry", limit=close + (profitTarget * syminfo.mintick))
strategy.exit("Trailing Stop", "Pullback Entry", stop=close - (trailingStop * syminfo.mintick), trail_points=trailingStop)
strategy.exit("Exit Condition", "Initial Entry", stop=close, when=exitCondition)
// Plot EMAs
plot(ema8, color=color.yellow, title="8 EMA", linewidth=1, style=plot.style_line)
plot(ema12, color=color.purple, title="12 EMA", linewidth=1, style=plot.style_line)
plot(ema24, color=color.blue, title="24 EMA", linewidth=1, style=plot.style_line)
plot(ema72, color=color.rgb(235, 255, 59), title="72 EMA", linewidth=1, style=plot.style_line)