트렌드 추적 이동 평균 RSI 전략

저자:차오장, 날짜: 2023-11-23 17:13:06
태그:

img

전반적인 설명

트렌드 추적 이동 평균 RSI 전략은 트렌드 분석과 과잉 구매 과잉 판매 지표를 모두 활용하는 자동화 주식 거래 전략이다. 이 전략은 시장 트렌드 방향을 결정하기 위해 간단한 이동 평균을 사용하며 상대 강도 지표 (RSI) 지표를 결합하여 거래 신호를 생성하여 트렌드 판단과 추적을 실현합니다.

전략 논리

이 전략은 세 가지 주요 부분으로 구성됩니다.

  1. 트렌드 판단: 200일 간 간단한 이동 평균으로 장기 트렌드를 계산하고, 30일 및 50일 간 간단한 이동 평균으로 단기 트렌드를 계산합니다. 단기 이동 평균이 장기 평균을 넘으면 상승 신호이며, 아래로 넘으면 하락 신호이며, 장기 및 단기 시장 트렌드를 결정합니다.

  2. 과잉 구매-대판 분석: 14일 RSI 지표를 계산합니다. RSI 80 이상은 과잉 구매 구역이고 20 이하는 과잉 판매 구역입니다. RSI 지표가 과잉 구매 구역에서 떨어지거나 과잉 판매 구역에서 상승 할 때 거래 신호가 생성됩니다.

  3. 진입 및 출구: 과잉 구매 또는 과잉 판매 신호가 확인되면, 방향이 트렌드 분석과 일치하면, 긴/단순 포지션이 열릴 것입니다. 단기 및 장기 이동 평균이 황금 십자가가있는 경우, 트렌드가 역전되고 있으며 기존 포지션이 닫힐 것이라고 판단됩니다.

이 전략은 가격 반전 시 시장에 적시에 진입 할 수 있으며, 추세 분석을 통합하여 비교적 우수한 유출 통제를 통해 소란스러운 거래를 필터링 할 수 있습니다.

이점 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 트렌드 분석과 과잉 매수와 과잉 매수 지표를 결합하여 소음을 필터링하고 시장의 전환을 식별합니다.
  2. 더 정확한 판단을 위해 장기 및 단기 두 가지의 추세를 고려합니다.
  3. 유동 평균을 스톱 로스 방법으로 사용해서 시장 변동성에 따라 스톱 로스 포인트를 설정할 수 있습니다.
  4. 엄격한 입국 조건은 가짜 탈출을 효과적으로 방지하는 데 도움이 됩니다.

위험 과 해결책

이 전략에는 몇 가지 위험도 있습니다.

  1. 시장이 장시간 범위 내에서 유지되면 빈번한 중요하지 않은 거래가 발생할 수 있습니다. 불필요한 거래를 피하기 위해 추가 필터를 추가 할 수 있습니다.
  2. 약간의 시간 지연 위험이 있습니다. 이동 평균 사이클 매개 변수를 단축하면 완화 될 수 있습니다.
  3. RSI 신호는 주식과 시장에 의해 영향을 받을 수 있습니다. 촛불 패턴과 같은 더 많은 요소가 효과를 판단하기 위해 결합되어야합니다.

최적화 방향

이 전략은 다음 측면에서 더 이상 최적화 될 수 있습니다.

  1. 음량, 촛불 패턴과 같은 더 많은 필터를 추가하여 신호 품질을 더욱 향상시킵니다.
  2. 이동 평균과 RSI 주기의 매개 변수를 최적화하여 다른 주식 특성에 맞출 수 있습니다.
  3. 동적 이동 평균을 구축하여 시장 변동성과 위험 욕구에 따라 매개 변수를 자동으로 조정합니다.
  4. 더 높은 정확도로 시장 트렌드를 결정하기 위해 기계 학습과 같은 더 고급 기술을 사용합니다.

요약

일반적으로, 트렌드 추적 이동 평균 RSI 전략은 트렌드 분석과 과잉 구매 과잉 판매 지표를 결합하여 시장 소음을 어느 정도 필터링하여 거래 신호를 더 정확하고 유효하게 만드는 매우 실용적인 전략 아이디어입니다. 최적화 도구와 매개 변수가 지속적으로 향상됨에 따라이 전략은 지속적으로 수익성있는 장기 거래 시스템으로 변할 수 있습니다.


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

//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mattehalen

// INPUT per TIMEFRAME
// 5min     = Legnth = 9, Source = ohlc4,MaxLoss = 1000 TrendMA = 200, ShortMA = 4, LongMA = 10
// 30min    = Legnth = 7, Source = ohlc4,MaxLoss = 1000 TrendMA = 200, ShortMA = 10, LongMA = 20

strategy("Mathias & Christer Timeframe RSI", shorttitle="M&C_RSI",overlay=true, process_orders_on_close = true, default_qty_type =  strategy.percent_of_equity, default_qty_value = 100)
len = input(9, title="Length", type=input.integer)
src = input(ohlc4, title="Source", type=input.source)
//show4h = input(true, title="show 4h", type=input.bool)
maxLoss = input(3000)

rsiCurrent = rsi(src, len)
//rsi4h = security(syminfo.ticker, "240", rsi(src, len))
rsi4h   = rsi(src, len)

//--------------------------------------------------
//MA
trendMAInput = input(200, title="trendMA", type=input.integer)
shortMAInput = input(30, title="shortMA", type=input.integer)
longMAInput = input(50, title="longMA", type=input.integer)

trendMA = ema(close,trendMAInput)
shortMA = ema(close,shortMAInput)
longMA  = ema(close,longMAInput)
plot(trendMA, color=color.black, linewidth=5)
plot(shortMA, color=color.red, linewidth=2)
plot(longMA, color=color.green, linewidth=2)
bgcolor(crossunder(shortMA,longMA) ? color.black : na, transp=10)

//--------------------------------------------------
//RSI
BuySignalBarssince = barssince(rsi4h[1]<rsi4h[0] and rsi4h[1]<20)
BuySignal       = (rsi4h[1]<rsi4h[0] and rsi4h[1]<20 and BuySignalBarssince[1]>10)
BuySignalOut   = crossunder(longMA[1],shortMA[1])
bgcolor(BuySignal ? color.green : na, transp=70)
bgcolor(BuySignalOut ? color.green : na, transp=10)



SellSignalBarssince = barssince(rsi4h[1]>rsi4h[0] and rsi4h[1]>80)
SellSignal      = (rsi4h[1]>rsi4h[0] and rsi4h[1]>80 and SellSignalBarssince[1]>10)
SellSignalOut   = crossunder(shortMA[1],longMA[1])
bgcolor(SellSignal ? color.red : na, transp=70)
bgcolor(SellSignalOut ? color.red : na, transp=10)


if BuySignal
    strategy.close("short", comment = "Exit short")
    strategy.entry("long", true)
    strategy.exit("Max Loss", "long", loss = maxLoss)

if BuySignalOut
    strategy.close("long", comment = "Exit Long")
if SellSignal
    // Enter trade and issue exit order on max loss.
    strategy.close("long", comment = "Exit Long")
    strategy.entry("short", false)
    strategy.exit("Max Loss", "short", loss = maxLoss)
if SellSignalOut
    // Force trade exit.
    strategy.close("short", comment = "Exit short")
    
//--------------------------------------------------
//ATR
MyAtr = atr(10)
AtrFactor = 10
mySLBuy  = close[BuySignalBarssince]
mySLSell = close[SellSignalBarssince]

plotchar(BuySignal, "BuySignal", "⬆", location.belowbar, color.lime,size =size.huge )
plotchar(BuySignalOut, "BuySignalOut", "█", location.belowbar, color.lime,size =size.small)
plotchar(SellSignal, "SellSignal", "⬇", location.abovebar ,color.red,size =size.huge)
plotchar(SellSignalOut, "SellSignalOut", "█", location.abovebar, color.red,size =size.small)




더 많은