
この戦略は,EMA交差,RSI偏差,30分トレンド識別,価格の枯渇などの技術指標を組み合わせて,市場トレンドと価格の曲折点を捉えることを目的としています.戦略は,EMA13とEMA26の交差を通してトレンドの方向を決定し,RSI偏差を使用して潜在的なトレンドの逆転を識別し,30分時間枠内のトレンド状態と価格の枯渇を考慮しながら,エントリーポイントを最適化します.
この戦略は,EMA交差,RSI偏差,30分トレンド識別および価格の尽きることなどの技術指標を組み合わせて,市場を複数の次元で分析し,トレンドと潜在的なターニングポイントを捕捉します.戦略の優点は,多次元分析,トレンド確認,ターニングポイントキャプチャおよびリスク制御にありますが,パラメータ最適化,トレンド転換,偽信号と突発事件などのリスクもあります.
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Cross Strategy with RSI Divergence, 30-Minute Trend Identification, and Price Exhaustion", overlay=true)
// Definição das médias móveis exponenciais para tendência de curto prazo (30 minutos)
EMA5_30min = ta.ema(close, 5)
EMA10_30min = ta.ema(close, 10)
// Definição das médias móveis exponenciais
EMA13 = ta.ema(close, 13)
EMA26 = ta.ema(close, 26)
// RSI com período padrão de 7
rsi = ta.rsi(close, 7)
// Detecção do cruzamento das EMAs
crossUp = ta.crossover(EMA13, EMA26)
crossDown = ta.crossunder(EMA13, EMA26)
// Detecção de divergência no RSI
bullishDivergence = ta.crossunder(close, EMA13) and ta.crossunder(rsi, 30)
bearishDivergence = ta.crossover(close, EMA13) and ta.crossover(rsi, 70)
// Geração de sinais de entrada
entrySignal = crossUp ? 1 : (crossDown ? -1 : 0)
// Abertura da posição
if (entrySignal == 1)
strategy.entry("Long", strategy.long)
else if (entrySignal == -1)
strategy.entry("Short", strategy.short)
// Fechamento da posição
if (entrySignal == 1 and ta.crossover(close, EMA26))
strategy.close("Long")
else if (entrySignal == -1 and ta.crossunder(close, EMA26))
strategy.close("Short")
// Comando de compra e venda
buySignal = crossUp and close > EMA13 and close > EMA26
sellSignal = crossDown and close < EMA13 and close < EMA26
// Aplicando a lógica de divergência RSI
if (bullishDivergence)
strategy.entry("Bullish Divergence", strategy.long)
if (bearishDivergence)
strategy.entry("Bearish Divergence", strategy.short)
// Identificação de tendência nos últimos 30 minutos
isUptrend30min = close > EMA5_30min and close > EMA10_30min
isDowntrend30min = close < EMA5_30min and close < EMA10_30min
// Identificação de exaustão do preço com base no RSI
isOversold = rsi < 30
isOverbought = rsi > 70
// Executando os sinais de compra e venda
if (buySignal and isUptrend30min and isOversold)
strategy.entry("Buy", strategy.long)
if (sellSignal and isDowntrend30min and isOverbought)
strategy.entry("Sell", strategy.short)