
A estratégia usa três médias móveis indexadas de diferentes períodos (EMA) para julgar a tendência do mercado e os sinais de compra e venda. A interseção entre a EMA rápida, a EMA lenta e a tendência de filtragem EMA, bem como a posição do preço em relação à tendência de filtragem EMA, compõem a lógica central da estratégia. A estratégia também introduziu o indicador de tendência Fukuiz como julgamento auxiliar, que em alguns casos pode desencadear a operação de equilíbrio.
A estratégia, através da combinação de vários períodos de EMA, e com a ajuda do indicador de tendência Fukuiz, constrói um quadro relativamente completo de julgamento de tendência e de negociação. A lógica da estratégia é clara, os parâmetros são ajustáveis e adaptáveis. Mas, ao mesmo tempo, existem alguns riscos potenciais, como atraso de sinal, distorção de julgamento de tendência, etc.
/*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")