
A estratégia é um sistema de auto-adaptação que combina o acompanhamento de tendências e negociações intercalares para julgar o estado do mercado por meio do índice de volatilidade (CI) e adotar a lógica de negociação correspondente de acordo com diferentes condições de mercado. Em mercados de tendências, a estratégia usa sinais de venda e venda de EMA e RSI; em mercados intercalares, a estratégia é baseada principalmente no máximo valor do indicador RSI. A estratégia também inclui um mecanismo de parada de perda para controlar o risco e bloquear os lucros.
O núcleo da estratégia é dividir o mercado em mercados de tendência (IC <38.2) e mercados intercalares (IC >61.8) através do índice de flutuação (IC <38.2) e dos dois estados (IC <61.8): no mercado de tendência, quando a EMA rápida (IC ciclos) atravessa a EMA lenta (IC <21 ciclos) e o RSI está abaixo de 70, abrem o gancho; quando a EMA lenta atravessa a EMA rápida e o RSI está acima de 30, abrem o gancho. No mercado intercalar, abrem o gancho quando o RSI está abaixo de 30, abrem o gancho quando estão acima de 70.
A estratégia, através da combinação de vários indicadores técnicos, constrói um sistema de negociação auto-adaptável, capaz de manter um desempenho estável em diferentes ambientes de mercado. A principal vantagem da estratégia reside na sua adaptabilidade ao mercado e no seu mecanismo de gestão de risco perfeito, mas também precisa prestar atenção a questões como a otimização de parâmetros e a dependência das condições de mercado.
/*backtest
start: 2024-12-19 00:00:00
end: 2024-12-26 00:00:00
period: 45m
basePeriod: 45m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nopology
//@version=6
strategy("CI, EMA, RSI", overlay=false)
// Input parameters
lengthCI = input(14, title="CI Length")
lengthRSI = input(14, title="RSI Length")
fastLength = input(9, title="Fast EMA Length")
slowLength = input(21, title="Slow EMA Length")
// Calculate CI
atr = ta.atr(lengthCI)
highLowRange = math.log10(math.max(high[lengthCI], high) - math.min(low[lengthCI], low))
sumATR = math.sum(atr, lengthCI)
ci = 100 * (math.log10(sumATR / highLowRange) / math.log10(lengthCI))
// Calculate RSI
rsi = ta.rsi(close, lengthRSI)
// Calculate EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
// Define conditions
trendingMarket = ci < 38.2
rangingMarket = ci > 61.8
bullishSignal = ta.crossover(fastEMA, slowEMA) and rsi < 70
bearishSignal = ta.crossover(slowEMA, fastEMA) and rsi > 30
// Plot indicators for visualization
plot(ci, title="Choppiness Index", color=color.purple, linewidth=2)
plot(fastEMA, title="Fast EMA", color=color.blue)
plot(slowEMA, title="Slow EMA", color=color.red)
// Strategy Execution
if (trendingMarket)
if (bullishSignal)
strategy.entry("Long", strategy.long)
if (bearishSignal)
strategy.entry("Short", strategy.short)
else if (rangingMarket)
if (rsi < 30)
strategy.entry("Long", strategy.long)
if (rsi > 70)
strategy.entry("Short", strategy.short)
// Close positions when conditions no longer met or reverse
if (trendingMarket and not bullishSignal)
strategy.close("Long")
if (trendingMarket and not bearishSignal)
strategy.close("Short")
if (rangingMarket and rsi > 40)
strategy.close("Long")
if (rangingMarket and rsi < 60)
strategy.close("Short")
// Optional: Add stop loss and take profit
stopLossPerc = input.float(2, title="Stop Loss (%)", minval=0.1, step=0.1) / 100
takeProfitPerc = input.float(4, title="Take Profit (%)", minval=0.1, step=0.1) / 100
strategy.exit("Exit Long", "Long", stop=close*(1-stopLossPerc), limit=close*(1+takeProfitPerc))
strategy.exit("Exit Short", "Short", stop=close*(1+stopLossPerc), limit=close*(1-takeProfitPerc))