
该策略使用了三条不同周期的指数移动平均线(EMA)来判断市场趋势和买卖信号。快速EMA、慢速EMA和趋势过滤EMA的交叉情况,以及价格相对于趋势过滤EMA的位置,共同构成了该策略的核心逻辑。同时,该策略还引入了Fukuiz趋势指标作为辅助判断,在某些情况下会触发平仓操作。
该策略通过多个周期EMA的组合,以及Fukuiz趋势指标的辅助,构建了一个相对完整的趋势判断和交易框架。策略逻辑清晰,参数可调,适应性强。但同时也存在一些潜在风险,如信号滞后、趋势判断偏差等。未来可以从参数优化、指标组合、风险管理等方面对策略进行进一步完善。
/*backtest
start: 2023-06-08 00:00:00
end: 2024-06-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EvilRed Trading Indicator Trend Filter", overlay=true)
// Parameters Definition
fastLength = input(9, title="Fast EMA Length")
slowLength = input(21, title="Slow EMA Length")
trendFilterLength = input(200, title="Trend Filter EMA Length")
// Moving Averages Calculation
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
trendEMA = ta.ema(close, trendFilterLength)
// Volatility Calculation
volatility = ta.stdev(close, 20)
// Add Fukuiz Trend Indicator
fukuizTrend = ta.ema(close, 14)
fukuizColor = fukuizTrend > fukuizTrend[1] ? color.green : color.red
plot(fukuizTrend, color=fukuizColor, title="Fukuiz Trend")
// Plotting Moving Averages
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.red, title="Slow EMA")
plot(trendEMA, color=color.orange, title="Trend Filter")
// Plotting Buy and Sell Signals
buySignal = ta.crossover(fastEMA, slowEMA) and fastEMA > slowEMA and close > trendEMA
sellSignal = ta.crossunder(fastEMA, slowEMA) and fastEMA < slowEMA and close < trendEMA
// Entry and Exit Conditions
if (strategy.position_size > 0 and fukuizColor == color.red)
strategy.close("Long", comment="Fukuiz Trend is Red")
if (strategy.position_size < 0 and fukuizColor == color.green)
strategy.close("Short", comment="Fukuiz Trend is Green")
if (buySignal)
strategy.entry("Long", strategy.long)
if (sellSignal)
strategy.entry("Short", strategy.short)
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")