
This strategy combines technical indicators such as EMA crossover, RSI divergence, 30-minute trend identification, and price exhaustion to capture market trends and price turning points. The strategy determines the trend direction using the crossover of EMA13 and EMA26, identifies potential trend reversals using RSI divergence, and considers the trend status within the 30-minute timeframe and price exhaustion conditions to optimize entry points.
This strategy analyzes the market from multiple dimensions by combining technical indicators such as EMA crossover, RSI divergence, 30-minute trend identification, and price exhaustion to capture trends and potential turning points. The strategy’s advantages lie in multi-dimensional analysis, trend confirmation, turning point capture, and risk control. However, it also faces risks such as parameter optimization, trend transitions, false signals, and unexpected events. In the future, the strategy can be optimized through dynamic parameter optimization, trend strength filtering, multi-timeframe confirmation, and the implementation of stop loss and take profit strategies to further improve its robustness and profitability.
/*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)