다중 시간 프레임 RSI 이동 평균 크로스오버 전략

저자:차오장, 날짜: 2023-11-16 16:28:22
태그:

img

전반적인 설명

멀티 타임프레임 RSI 이동 평균 크로스오버 전략 (Multi-Timeframe RSI Moving Average Crossover Strategy) 은 여러 시간 프레임에 걸쳐 트렌드를 따르는 전략이다. 여러 시간 프레임에 걸쳐 RSI 지표를 사용하여 각 시간 프레임의 RSI의 가중 이동 평균을 취한다. 최종 신호는 모든 RSI 이동 평균을 두 가지 포괄적 인 지표로 결합하고 크로스오버 신호를 거래함으로써 생성된다. 이는 전형적인 이중 이동 평균 크로스오버 시스템이다.

원칙

이 전략은 먼저 여러 시간 프레임 (1 분, 5 분, 15 분, 등) 에 대한 RSI 지표를 계산합니다. 그런 다음 RSI 이동 평균 라인을 얻기 위해 각 시간 프레임에 대한 RSI의 15 기간 VMA (중량 이동 평균) 이 필요합니다.

그 후, 다른 시간 프레임의 모든 RSI 이동 평균은 두 개의 신호 - 빠른 라인과 느린 라인으로 동일하게 결합됩니다. 빠른 라인은 100 기간 EMA이며 느린 라인은 150 기간 EMA입니다.

빠른 선이 느린 선 위에 넘어가면 구매 신호가 생성됩니다. 빠른 선이 느린 선 아래에 넘어가면 판매 신호가 생성됩니다. 이러한 방식으로 멀티 타임프레임 RSI를 결합함으로써 크로스오버 신호는 단기 시장 소음을 필터링하는 동안 트렌드를 효과적으로 추적 할 수 있습니다.

장점

  1. 여러 시간 프레임을 결합하면 가격 곡선을 매끄럽게하고 잘못된 파장을 효과적으로 피할 수 있습니다.

  2. RSI는 새로운 최고/하위치를 추구하고 싶지 않은 과잉 구매/ 과잉 판매 수준을 나타냅니다.

  3. 이중 이동 평균은 단일 이동 평균 시스템보다 더 나은 유지 효과를 가지고 있습니다.

  4. SMA 대신 VMA를 사용하면 단기 변동의 영향을 줄입니다.

위험성

  1. 멀티 타임프레임 전략은 광범위한 매개 변수 조정이 필요하며, 부적절한 설정으로 인해 좋은 항목이 누락되거나 늦은 항목이 발생할 수 있습니다.

  2. 이동평균은 곡선 적응이 안 좋고, 트렌드 전환점에서는 실적이 좋지 않습니다.

  3. RSI의 오차는 자주 발생하기 때문에 반전 신호를 관찰해야 합니다.

솔루션: 타임프레임 매개 변수를 최적화; 추세를 결정하기 위해 MACD와 같은 다른 지표와 결합; RSI 분차 신호에 주의하십시오.

최적화 방향

  1. 트렌드를 더 잘 파악하기 위해 시간 프레임과 매개 변수 설정을 최적화하십시오.

  2. 위험 통제에 스톱 로스를 추가하는 것도 고려해야 합니다.

  3. 추세와 차이에 대한 더 나은 결정을 위해 다른 지표를 결합하십시오.

  4. 가장 좋은 유지 효과를 위해 다른 유지 기간 매개 변수를 테스트합니다.

결론

멀티 타임프레임 RSI 이동 평균 크로스오버 전략은 이동 평균 시스템을 사용하여 여러 시간 프레임에서 RSI 지표를 결합하여 거래 신호를 생성합니다. 이는 전형적인 멀티 타임프레임 트렌드 추적 전략입니다. 그것의 강점은 트렌드를 효과적으로 추적하고 소음을 필터하는 데 있습니다. 그러나 매개 변수 조정 및 위험 통제는 주의가 필요합니다. 추가 최적화로 강력한 트렌드 추적 시스템으로 변할 수 있습니다.


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

//@version=4
strategy(title="RSI multitimeframe SMA crossover", shorttitle="RSI multitimeframe strategy", default_qty_type= strategy.percent_of_equity, margin_long=50, default_qty_value=150)

res1 = input(title="Res 01", type=input.resolution, defval="1")
res2 = input(title="Res 0", type=input.resolution, defval="5")
res3 = input(title="Res 1", type=input.resolution, defval="15")
res4 = input(title="Res 2", type=input.resolution, defval="15")
res5 = input(title="Res 3", type=input.resolution, defval="15")
res6 = input(title="Res 4", type=input.resolution, defval="30")
res7 = input(title="Res 5", type=input.resolution, defval="45")
res8 = input(title="Res 6", type=input.resolution, defval="60")



lengthRSI = input(15, minval=1)
lengthMA = input(15, minval=1)
lengthFMA = input(100, minval=1)
lengthFMA2 = input(150, minval=1)
Long_yes = input(defval=1, title="Long trades 0 or 1", minval=0, maxval=1)
Short_yes = input(defval=0, title="Short trades 0 or 1", minval=0, maxval=1)
src = close

// === INPUT BACKTEST RANGE ===
fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)
fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)
fromYear  = input(defval = 2020, title = "From Year",       type = input.integer, minval = 1970)
thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)
thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)
thruYear  = input(defval = 2112, title = "Thru Year",       type = input.integer, minval = 1970)

// === INPUT SHOW PLOT ===
showDate  = input(defval = true, title = "Show Date Range", type = input.bool)

// === FUNCTION EXAMPLE ===
start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false       // create function "within window of time"



// stop loss 
longLossPerc = input(title="Long Stop Loss (%)", type=input.float, minval=0.0, step=0.5, defval=10) * 
   0.01
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)

shortLossPerc = input(title="Short Stop Loss (%)", type=input.float, minval=0.0, step=0.5, defval=10) * 
   0.01
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)


rsi1 = rsi(src, lengthRSI)
MA1 = vwma(rsi1, lengthMA)






outD1 = security(syminfo.tickerid, res1, MA1)
outD2 = security(syminfo.tickerid, res2, MA1)
outD3 = security(syminfo.tickerid, res3, MA1)
outD4 = security(syminfo.tickerid, res4, MA1)
outD5 = security(syminfo.tickerid, res5, MA1)
outD6 = security(syminfo.tickerid, res6, MA1)
outD7 = security(syminfo.tickerid, res7, MA1)
outD8 = security(syminfo.tickerid, res8, MA1)




//plot_d0 = outD0
//plot_d1 = outD1
//plot_d2 = outD2
//plot_d3 = outD3
//plot_d4 = outD4
//plot_d5 = outD5
//plot_d6 = outD6

out_multi = ema(outD1+outD2+outD3+outD4+outD5+outD6+outD7+outD8, lengthFMA)
out_multi2 = ema(outD1+outD2+outD3+outD4+outD5+outD6+outD7+outD8, lengthFMA2)
//out_multi1 = outD2+outD3+outD4
//out_multi2 = outD4+outD5+outD6

//col0 = outD0 < 20 ? color.lime : outD0 > 80 ? color.red : color.blue
//col1 = outD1 < 20 ? color.lime : outD1 > 80 ? color.red : color.blue
//col2 = outD2 < 20 ? color.lime : outD2 > 80 ? color.red : color.blue
//col3 = outD3 < 20 ? color.lime : outD3 > 80 ? color.red : color.blue
//col4 = outD4 < 20 ? color.lime : outD4 > 80 ? color.red : color.blue
//col5 = outD5 < 20 ? color.lime : outD5 > 80 ? color.red : color.blue
//col6 = outD6 < 20 ? color.lime : outD6 > 80 ? color.red : color.blue


// plot(plot_d0,linewidth=2, color=col0)
// plot(plot_d1, linewidth=2, color=col1)
// plot(plot_d2,linewidth=2, color=col2)
// plot(plot_d3,linewidth=2, color=col3)
// plot(plot_d4,linewidth=2, color=col4)
// plot(plot_d5,linewidth=2, color=col5)
// plot(plot_d6,linewidth=2, color=col6)

long=(out_multi/8)
short=(out_multi2/8)

plot(long, linewidth=1, color=color.green)
plot(short, linewidth=1, color=color.red)

long1=crossover(long,short)
short1=crossunder(long,short)

h0 = hline(65, "Upper Band", color=color.red, linestyle=hline.style_solid, linewidth=2 )
h1 = hline(35, "Lower Band", color=color.green, linestyle=hline.style_solid, linewidth=2)


strategy.entry("buy", strategy.long, when=long1 and window() and Long_yes > 0) 
if strategy.position_size > 0
    strategy.exit(id="XL STP", stop=longStopPrice)
strategy.close("buy",when=short1 )

strategy.entry("sell", strategy.short, when=short1 and window() and Short_yes > 0) 
if strategy.position_size < 0
    strategy.exit(id="XS STP", stop=shortStopPrice)
strategy.close("buy",when=long1 )



더 많은