
Chiến lược này kết hợp các chỉ số kỹ thuật như giao dịch EMA, RSI, nhận dạng xu hướng 30 phút và giá hết, nhằm mục đích nắm bắt xu hướng thị trường và điểm biến giá. Chiến lược xác định hướng xu hướng thông qua giao dịch EMA13 và EMA26, sử dụng RSI để nhận diện sự đảo ngược xu hướng tiềm năng, đồng thời xem xét tình trạng xu hướng và giá hết trong khung thời gian 30 phút để tối ưu hóa điểm vào.
Chiến lược này phân tích thị trường trên nhiều chiều để nắm bắt xu hướng và các ngõ ngách tiềm năng bằng cách kết hợp các chỉ số kỹ thuật như giao dịch EMA, RSI deviation, nhận dạng xu hướng 30 phút và giá hết sức. Ưu điểm của chiến lược là phân tích đa chiều, xác nhận xu hướng, nắm bắt ngõ ngách và kiểm soát rủi ro, nhưng cũng có các rủi ro như tối ưu hóa tham số, chuyển hướng, chuyển đổi tín hiệu giả và sự kiện bất ngờ.
/*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)