변동성 포착 RSI-볼링거 밴드 전략

저자:차오장, 날짜: 2023-12-01 14:17:55
태그:

img

전반적인 설명

변동성 캡처 RSI-볼링거 밴드 전략 (Volatility Capture RSI-Bollinger Band strategy) 은 거래 신호를 생성하기 위해 볼링거 밴드 (BB), 상대 강도 지수 (RSI) 및 간단한 이동 평균 (SMA) 의 개념을 통합하는 거래 전략이다. 이 전략의 독특함은 폐쇄 가격에 따라 상위 및 하위 볼링거 밴드 사이의 동적 수준을 계산한다는 것입니다. 이 독특한 기능은 전략이 시장 변동성과 가격 움직임에 적응 할 수있게합니다.

암호화폐와 주식 시장은 매우 변동적이기 때문에 볼링거 밴드를 사용하는 전략에 적합합니다. RSI는 이러한 종종 투기적인 시장에서 과잉 구매 또는 과잉 판매 상황을 식별하는 데 도움이 될 수 있습니다.

어떻게 작동 합니까?

동적 볼링거 밴드 (Dynamic Bollinger Band): 전략은 먼저 사용자 정의 길이와 곱자에 기초하여 상부 및 하부 볼링거 밴드를 계산합니다. 그 다음 볼링거 밴드와 폐쇄 가격을 사용하여 현재 볼링거 밴드 값을 동적으로 조정합니다. 마지막으로 가격이 현재 볼링거 밴드를 넘을 때 긴 신호를 생성하고 가격이 아래로 넘을 때 짧은 신호를 생성합니다.

RSI: 사용자가 신호를 위해 RSI를 사용하는 것을 선택하면 전략은 또한 RSI와 SMA를 계산하고 추가 장기 및 단기 신호를 생성하는 데 사용합니다. RSI 신호는 Use RSI for signals 옵션이 활성화되면만 사용됩니다.

전략은 선택된 거래 방향을 확인하고 그에 따라 긴 또는 짧은 포지션을 입력합니다.

마지막으로, 전략은 닫기 가격이 현재 볼링 밴드 아래/오래를 가로질러 긴/단한 포지션을 마칠 때 포지션을 종료합니다.

이점 분석

이 전략은 볼링거 밴드, RSI 및 SMA의 강점을 결합하여 시장 변동에 적응하고 변동을 동적으로 포착하고 과잉 구매 / 과잉 판매 수준에서 거래 신호를 생성합니다.

RSI는 볼링거 신호를 보완하여 범위 시장에서 잘못된 입력을 피합니다. 단장, 단장 또는 두 방향 모두 허용하면 다른 시장 조건을 충족합니다.

사용자 정의 가능한 매개 변수들은 개인의 위험 선호도에 따라 조정할 수 있습니다.

위험 분석

이 전략은 기술적 지표에 의존하고 있으며 근본적인 큰 반전을 예측할 수 없습니다.

부적절한 볼링거 매개 변수 설정은 너무 빈번하거나 너무 희박한 신호를 생성 할 수 있습니다.

쌍방향 거래는 위험을 증가시킵니다.

위험 조절을 위해 정지를 사용하는 것이 좋습니다.

최적화 방향

  1. MACD와 같은 다른 필터를 필터 신호에 추가합니다.

  2. 스톱 로스 전략을 적용하세요.

  3. 볼링거와 RSI 매개 변수를 최적화하세요.

  4. 다른 제품과 시간 프레임에 대한 매개 변수를 조정합니다.

  5. 실제 조건에 맞는 라이브 튜닝 매개 변수를 고려하세요.

요약

변동성 캡처 RSI-볼링거 전략은 기술 지표에 기반한 전략으로 볼링거 밴드, RSI 및 SMA의 강점을 결합하여 시장 변동을 포착하기 위해 볼링거 밴드를 동적으로 조정합니다. 이 전략은 높은 사용자 정의와 최적화를 허용하지만 근본적인 변화를 예측할 수 없습니다. 실제 거래 검증 및 매개 변수 조정 또는 필요한 경우 위험을 줄이기 위해 다른 지표를 추가하는 것이 좋습니다.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

//@version=5
// Define the strategy settings
strategy('Volatility Capture RSI-Bollinger - Strategy [presentTrading]', overlay=true)

// Define the input parameters for the indicator
priceSource  = input.source(title='Source', defval=hlc3, group='presentBollingBand') // The price source to use
lengthParam   = input.int(50, 'lengthParam', minval=1, group='presentBollingBand') // The length of the moving average
multiplier = input.float(2.7183, 'Multiplier', minval=0.1, step=.1, group='presentBollingBand') // The multiplier for the ATR
useRSI = input.bool(true, 'Use RSI for signals', group='presentBollingBand') // Boolean input to decide whether to use RSI for signals
rsiPeriod = input.int(10, 'RSI Period', minval=1, group='presentBollingBand') // The period for the RSI calculation
smaPeriod = input.int(5, 'SMA Period', minval=1, group='presentBollingBand') // The period for the SMA calculation
boughtRange = input.float(55, 'Bought Range Level', minval=1, group='presentBollingBand') // The level for the bought range
soldRange = input.float(50, 'Sold Range Level', minval=1, group='presentBollingBand') // The level for the sold range

// Add a parameter for choosing Long or Short
tradeDirection = input.string("Both", "Trade Direction", options=["Long", "Short", "Both"], group='presentBollingBand') // Dropdown input for trade direction

// Calculate the bollingerBand
barIndex = bar_index // The current bar index
upperBollingerBand = ta.sma(high, lengthParam) + ta.stdev(high, lengthParam) * multiplier // Calculate the upper Bollinger Band
lowerBollingerBand = ta.sma(low, lengthParam) - ta.stdev(low, lengthParam) * multiplier // Calculate the lower Bollinger Band

var float presentBollingBand = na // Initialize the presentBollingBand variable
crossCount = 0 // Initialize the crossCount variable

// Calculate the buy and sell signals
longSignal1 = ta.crossover(priceSource, presentBollingBand) // Calculate the long signal
shortSignal1 = ta.crossunder(priceSource, presentBollingBand) // Calculate the short signal

// Calculate the RSI
rsiValue = ta.rsi(priceSource, rsiPeriod) // Calculate the RSI value
rsiSmaValue = ta.sma(rsiValue, smaPeriod) // Calculate the SMA of the RSI value

// Calculate the buy and sell signals
longSignal2 = rsiSmaValue > boughtRange // Calculate the long signal based on the RSI SMA
shortSignal2 = rsiSmaValue < soldRange // Calculate the short signal based on the RSI SMA

presentBollingBand := na(lowerBollingerBand) or na(upperBollingerBand)?0.0 : close>presentBollingBand?math.max(presentBollingBand,lowerBollingerBand) : close<presentBollingBand?math.min(presentBollingBand,upperBollingerBand) : 0.0


if (tradeDirection == "Long" or tradeDirection == "Both") and longSignal1 and (useRSI ? longSignal2 : true) // Use RSI for signals if useRSI is true
    presentBollingBand := lowerBollingerBand // If the trade direction is "Long" or "Both", and the long signal is true, and either useRSI is false or the long signal based on RSI is true, then assign the lowerBollingerBand to the presentBollingBand.
    strategy.entry("Long", strategy.long) // Enter a long position.

if (tradeDirection == "Short" or tradeDirection == "Both") and shortSignal1 and (useRSI ? shortSignal2 : true) // Use RSI for signals if useRSI is true
    presentBollingBand := upperBollingerBand // If the trade direction is "Short" or "Both", and the short signal is true, and either useRSI is false or the short signal based on RSI is true, then assign the upperBollingerBand to the presentBollingBand.
    strategy.entry("Short", strategy.short) // Enter a short position.

// Exit condition
if (strategy.position_size > 0 and ta.crossunder(close, presentBollingBand)) // If the strategy has a long position and the close price crosses under the presentBollingBand, then close the long position.
    strategy.close("Long")
if (strategy.position_size < 0 and ta.crossover(close, presentBollingBand)) // If the strategy has a short position and the close price crosses over the presentBollingBand, then close the short position.
    strategy.close("Short")

//~~ Plot
plot(presentBollingBand,"presentBollingBand", color=color.blue) // Plot the presentBollingBand on the chart.

더 많은