Tendência após estratégia de negociação baseada no MACD e no RSI

Autora:ChaoZhang, Data: 2024-01-23 12:03:23
Tags:

img

Resumo

Princípios

A estratégia utiliza principalmente os indicadores MACD e RSI para gerar sinais de negociação.

RSI significa Relative Strength Index (Índice de Força Relativa). Reflete situações de sobrecompra / sobrevenda, comparando os ganhos e perdas médios ao longo de um período. Esta estratégia define o período RSI como 14.

Forças

  • Os sinais MACD e os filtros do RSI localizam efetivamente a direção da tendência, evitando perdas desnecessárias de falhas

Riscos e soluções

Os principais riscos desta estratégia incluem:

Orientações de otimização

A estratégia pode ser melhorada nos seguintes aspectos:

  1. Otimizar os parâmetros MACD para reduzir os sinais ruidosos

  2. Melhorar o filtro RSI para melhor eficácia

  3. Teste outros indicadores de confirmação como KD, Bollinger Bands, etc.

  4. Utilize o aprendizado de máquina para otimização de parâmetros

  5. Incorporar futuros de índices de ações, opções de cobertura

Conclusão


/*backtest
start: 2023-01-16 00:00:00
end: 2024-01-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Al-Sat Sinyali ve Teyidi", overlay=true)

// MACD (Hareketli Ortalama Yakınsaklık Sapma)
[macdLine, signalLine, _] = ta.macd(close, 5, 13, 5)

// RSI (Göreceli Güç Endeksi)
rsiValue = ta.rsi(close, 14)

// RSI Filtresi
rsiOverbought = rsiValue > 70
rsiOversold = rsiValue < 30

// MACD Sinyalleri
buySignalMACD = ta.crossover(macdLine, signalLine) and not rsiOverbought
sellSignalMACD = ta.crossunder(macdLine, signalLine) and not rsiOversold

// Al-Sat Stratejisi
if (buySignalMACD and close[1] != close) // Al sinyali ve bir önceki mumdan farklı renkte ise
    strategy.entry("Buy", strategy.long)

if (sellSignalMACD and close[1] != close) // Sat sinyali ve bir önceki mumdan farklı renkte ise
    strategy.entry("Sell", strategy.short)

// Teyit için bir sonraki mumu bekleme
strategy.close("Buy", when=ta.crossover(close, open))
strategy.close("Sell", when=ta.crossunder(close, open))

// Varsayımsal bir sonraki mumun kapanış fiyatını hesapla
nextBarClose = close[1]
plot(nextBarClose, color=color.blue, linewidth=2, title="Tahmin Edilen Kapanış Fiyatı")

// Görselleştirmeyi devre dışı bırakma
plot(na)

// Al-Sat Etiketleri
plotshape(series=buySignalMACD, title="Al Sinyali", color=color.green, style=shape.triangleup, location=location.belowbar, size=size.small, text="Al")
plotshape(series=sellSignalMACD, title="Sat Sinyali", color=color.red, style=shape.triangledown, location=location.abovebar, size=size.small, text="Sat")


Mais.