RSI MACD 크로스오버 듀플 MA 추적 전략

저자:차오장, 날짜: 2023-10-23 17:00:44
태그:

img

전반적인 설명

이 전략은 RSI 지표, MACD 지표 및 이중 이동 평균을 결합하여 변동성 시장에서 트렌드 추적 및 위치 효과를 달성합니다. 과잉 구매 및 과잉 판매 조건을 판단하기 위해 RSI 지표를 사용하며, 빠른 및 느린 MA 크로스오버와 함께 입점 및 출구 지점을 결정하기 위해 MACD를 사용하며, 트렌드 중에 소란스러운 거래 기회를 필터링하기 위해 이중 MA를 사용합니다.

전략 논리

  1. 과잉 구매 및 과잉 판매를 위한 RSI 지표 계산
  • 가격 변화 상승 추세와 하락 추세를 계산

  • 가격변화에 기초하여 RSI를 계산합니다

  • 과잉 구매 및 과잉 판매 수준을 결정

  1. 크로스오버의 MACD를 계산합니다.
  • 빠른 MA, 느린 MA 및 신호 라인을 계산합니다.

  • 골든 크로스에서 길게 들어가 죽음의 크로스에서 나가

  • 크로스오버 상황을 그래프로 그려라

  1. 이중 MA 필터를 적용합니다
  • 빠른 이동 평균과 느린 이동 평균을 계산

  • 빠른 MA가 느린 MA를 넘을 때만 거래를 고려하십시오.

  • 소음을 필터링하고 추세를 따르십시오.

  1. 진입을 위한 조합 지표
  • RSI, MACD 및 이중 MA와 함께 입력 신호를 필터

  • 전략의 정확성 및 안정성 향상

이점 분석

  • 여러 지표의 조합은 정확성을 향상시킵니다.

  • 트렌드를 따라 잡음을 필터하고 안정성을 향상시킵니다

  • RSI는 잠재적인 반전 지점을 감지합니다.

  • MACD 크로스오버는 간단한 입출 신호를 제공합니다.

  • 이중 MA는 대부분의 반동향 거래를 제거합니다.

  • 몇 가지 매개 변수와 함께 이해하기 쉽고, 학습에 좋습니다

위험 분석

  • 여러 지표에 대한 과도한 적합성 위험

  • 이중 MA는 유연성을 희생시키고 기회를 놓칠 수 있습니다.

  • RSI와 MACD 매개 변수는 신중한 선택이 필요합니다.

  • 기호에 기반한 스톱 손실에 주의를 기울여

  • 매개 변수를 주기적으로 재조정해야 합니다

최적화 방향

  • 다른 기호에 대한 RSI 매개 변수를 조정

  • 더 나은 추적을 위해 이중 MA 기간을 최적화하십시오.

  • 단일 거래 손실을 제어하기 위해 스톱 손실을 추가하십시오.

  • 더 많은 지표를 포함하여 콤보를 풍부하게

  • 자동 튜닝을 위한 적응적 매개 변수 모델을 개발

요약

이 전략은 트렌드를 식별하고 추적하기 위해 RSI, MACD 및 이중 MA를 결합하고 여러 계층을 통해 신호를 필터합니다. 초보자가 배우고 개선하는 데 매우 적합합니다. 이점은 단순성과 적응력입니다. 매개 변수의 세밀한 조정으로 괜찮은 안정적인 수익을 창출 할 수 있습니다. 다음 단계는 더 많은 지표를 추가하고 다른 시장 환경에 대한 자동 최적화를 위해 적응 매개 변수 모델을 개발하는 것을 포함 할 수 있습니다.


/*backtest
start: 2023-09-22 00:00:00
end: 2023-10-22 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3

// strategy(title="RSI MACD", precision = 6, pyramiding = 1, default_qty_type = strategy.percent_of_equity, default_qty_value = 99, commission_type = strategy.commission.percent, commission_value = 0.25, initial_capital = 1000)

// Component Code Start
// Example usage:
// if testPeriod()
//   strategy.entry("LE", strategy.long)
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(01, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2019, "Backtest Stop Year")
testStopMonth = input(7, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() => true
// Component Code Stop

//standard rsi template
src = ohlc4, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=#87ff1a)
band1 = hline(80)
band = hline(50)
band0 = hline(20)
fill(band1, band0, color=purple, transp=90)

//macd

fast_length = input(title="Fast Length",  defval=9)
slow_length = input(title="Slow Length",  defval=72)
signal_length = input(title="Signal Length",  defval=9)

fast_ma = sma(rsi, fast_length) 
slow_ma = sma(rsi, slow_length) 
shortma = sma(ohlc4, fast_length)
longma = sma(ohlc4, slow_length)
controlmainput = input(title = "Control MA", defval = 234)
controlma = sma(ohlc4, controlmainput)
macdx = fast_ma - slow_ma
signalx = sma(macdx, signal_length)
hist = macdx - signalx
ma_hist = shortma - controlma
macd = macdx + 50
signal = signalx + 50

plot(macd,"macd", color = fuchsia)
plot(hist,"hist", style = histogram, color = fuchsia)
//plot(ma_hist,"ma hist", style = histogram, color = orange)
plot(signal,"signal", color = white)

//input
control_buy_toggle = input(true, "Buy on crossover control MA?", type = bool)
buy_on_control = control_buy_toggle == true? true : false

//conditions
buy = buy_on_control == true? ma_hist > 0 and shortma > longma and crossover(macd,signal) or crossover(shortma, controlma) : ma_hist > 0 and shortma > longma and crossover(macd,signal)
sell = ma_hist > 0 and shortma > longma and crossunder(macd,signal)
stop = crossunder(shortma, longma) or crossunder(shortma, controlma)

plotshape(buy,"buy", shape.triangleup, location.bottom, green, size = size.tiny)
plotshape(sell,"sell", shape.triangledown, location.bottom, red, size = size.tiny)
plotshape(stop,"stop",shape.circle,location.bottom, white, size = size.tiny)

if testPeriod()
    strategy.entry("buy", true, when = buy, limit = close)
    strategy.close("buy", when = sell)
    strategy.close("buy", when = stop)
    



더 많은