RSI와 볼링거 밴드 두 가지 전략

저자:차오장, 날짜: 2023-12-12 11:53:49
태그:

img

전반적인 설명

이 전략의 핵심 아이디어는 상대 강도 지수 (RSI) 와 볼링거 밴드 (Bollinger Bands) 를 결합하여 이중 거래 신호를 필터하고 잘못된 신호의 간섭을 최대한 줄이고 신호 품질을 향상시키는 것입니다.

RSI 지표는 가격이 볼링거 밴드의 상부 및 하부 레일을 뚫거나 끌어당기는 동안 과반 구매 또는 과반 판매 신호를 표시 할 때 거래 기회가 나타날 것입니다. 두 가지 다른 지표의 장점을 결합하여 시장 변동의 통계적 특성과 시장 참여자의 긴 / 짧은 입장을 모두 고려하여 포괄적인 판단을 형성합니다.

전략 원칙

RSI 부분에서는 서로 다른 사이클 길이를 가진 두 개의 RSI 인디케이터를 동시에 모니터링합니다. 짧은 사이클을 가진 하나는 과잉 구매 및 과잉 판매 신호를 캡처하는 데 사용되며, 더 긴 사이클을 가진 하나는 트렌드 반전을 확인하는 데 사용됩니다. 짧은 사이클 RSI가 과잉 구매 / 과잉 판매를 표시하고 긴 사이클 RSI가 반전을 표시하면 거래 기회가 형성되었다고 믿습니다.

볼링거 밴드 부분에서는 가격이 상부와 하부 레일을 통과하는지 모니터링합니다. 볼링거 밴드의 상부 레일을 통과하는 것은 판매 포인트이며, 하부 레일을 통과하는 것은 구매 포인트입니다. 동시에, 우리는 또한 가격이 역전 기회를 적시에 포착 할 수 있도록 볼링거 밴드에 다시 당겨지는지 모니터링합니다.

RSI와 볼링거 밴드 신호가 동시에 나타나면 거래 기회가 형성되어 거래 명령이 발급된다고 믿습니다.

이점 분석

  • 이중 지표 필터링은 더 높은 신뢰성을 제공하며 불필요한 거래를 피합니다.
  • 트렌드 및 역전 시장 단계에서 기회를 포착합니다
  • 필요에 따라 조정 가능한 설정에 대한 구성 가능한 매개 변수
  • 임베디드 시간 및 돈 관리

위험 분석

  • 부적절한 볼링거 밴드 매개 변수 설정으로 인해 잘못된 신호가 발생할 수 있습니다.
  • 극심한 시장 변동에 대처할 수 없습니다.
  • RSI의 오차는 잘못된 신호를 생성할 수 있습니다.
  • 다른 제품과 주기에 적응하기 위해 필요한 매개 변수 최적화

위험은 매개 변수 최적화, 적절한 위치 감소, 수동 개입 등을 통해 피할 수 있고 제어 할 수 있습니다.

최적화 방향

  • RSI 매개 변수를 조정하여 과잉 구매/ 과잉 판매 판단을 최적화합니다.
  • 브레이크아웃 전략을 최적화하기 위해 볼링거 밴드 폭을 조정합니다.
  • 위치 관리 메커니즘 추가
  • 스톱 로스 전략을 추가
  • 더 많은 지표를 통합하여 다중 요소 모델을 구축

결론

RSI와 볼링거 밴드 이중 전략은 양 지표의 강점을 완전히 활용하여 고품질의 신호를 생성합니다. 적절한 매개 변수 최적화 및 위험 관리로 안정적인 투자 수익을 얻을 수 있습니다. 더 많은 신호와 모델을 통합하는 것도 잠재적 인 미래 방향입니다.


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

//@version=4
strategy("Ezieh Str.v2", shorttitle="Ezieh Str.v2", overlay=true, pyramiding=10, currency=currency.USD, slippage=3, commission_type=strategy.commission.cash_per_order, commission_value=0.04, initial_capital=1000)



UseDateFilter  = input(title="Enable Date Filter"         ,type=input.bool    ,defval=false                               ,group="Date & Time" ,tooltip="Turns on/off date filter")
StartDate      = input(title="Start Date Filter"          ,type=input.time    ,defval=timestamp("1 Jan 2000 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to start excluding trades")
EndDate        = input(title="End Date Filter"            ,type=input.time    ,defval=timestamp("1 Jan 2100 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to stop excluding trades")
UseTimeFilter  = input(title="Enable Time Session Filter" ,type=input.bool    ,defval=false                               ,group="Date & Time" ,tooltip="Turns on/off time session filter")
TradingSession = input(title="Trading Session"            ,type=input.session ,defval="1000-2200:1234567"                 ,group="Date & Time" ,tooltip="No trades will be taken outside of this range")

In(t)      => na(time(timeframe.period, t)) == false
TimeFilter = (UseTimeFilter and not In(TradingSession)) or not UseTimeFilter
DateFilter = time >= StartDate and time <= EndDate

DateTime = (UseDateFilter ? not DateFilter : true) and (UseTimeFilter ? In(TradingSession) : true) 

///////////// RSI
L_RSI_Length     = input(7  , title="L_Length")
L_RSI_OverSold   = input(45 , title="L_OverSold")
S_RSI_Length     = input(14 , title="S_Length")
S_RSI_OverBought = input(65 , title="S_OverBought")

price = close
Lvrsi = rsi(price, L_RSI_Length)
Svrsi = rsi(price, S_RSI_Length)

///////////// Bollinger Bands
BBlength = input(title="Bollinger Period Length", type=input.integer, defval=100, minval=2)
BBmult = 2.1 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
plot(BBbasis, color=color.aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=color.silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=color.silver,title="Bollinger Bands Lower Line")
fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")



///////////// Condition
LongCondition  = crossover(Lvrsi, L_RSI_OverSold)    and crossover(close  ,BBlower)
ShortCondition = crossunder(Svrsi, S_RSI_OverBought) and crossunder(close,BBupper)
Longexcon      = crossunder(low, BBupper)
Shortexcon     = crossover(low, BBlower)

qt = round(strategy.equity/price, 3)

///////////// RSI + Bollinger Bands Strategy
if (not na(Lvrsi))

    if LongCondition and DateTime
        strategy.entry("RSI_BB_L", strategy.long, qty=qt,  comment="Long")
    else
        strategy.cancel(id="RSI_BB_L")
        
    if Longexcon
        strategy.close("RSI_BB_L", qty_percent = 100, comment = "L_exit")
    
    if ShortCondition and DateTime
        strategy.entry("RSI_BB_S", strategy.short, qty=qt,  comment="Short")
    else
        strategy.cancel(id="RSI_BB_S")
        
    if Shortexcon
        strategy.close("RSI_BB_S", qty_percent = 100, comment = "S_exit")
    
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

더 많은