변동성 지수와 스토카스틱 오시레이터에 기초한 다기간에 거래 전략

저자:차오장, 날짜: 2023-12-21 14:34:42
태그:

img

전반적인 설명 이 전략은 효율적인 브레이크아웃 엔트리와 과잉 구매/ 과잉 판매 출입을 달성하기 위해 다양한 기간에 걸쳐 지표의 구성을 통해 변동성 지수 VIX와 스토카스틱 오시레이터 RSI를 결합합니다. 전략은 최적화 할 수있는 넓은 공간을 가지고 있으며 다른 시장 환경에 적응 할 수 있습니다.

원칙

  1. VIX 변동성 지수를 계산합니다. 변동성을 계산하기 위해 지난 20 일 동안 가장 높고 가장 낮은 가격을 사용합니다. 높은 VIX는 시장 공황을 나타냅니다. 낮은 VIX는 시장의 자만함을 나타냅니다.

  2. RSI 오시일레이터를 계산합니다. 지난 14일 동안의 가격 변화를 취합니다. RSI 70 이상은 과잉 구매 조건을 제안하고 RSI 30 이하는 과잉 판매 조건을 제안합니다.

  3. 두 지표를 조합하면 VIX가 상위 계단이나 가장 높은 퍼센틸을 넘을 때 장면을 취하고 RSI가 70을 넘을 때 장면을 닫습니다.

장점

  1. 포괄적 인 시장 타이밍 평가를 위해 여러 지표를 통합합니다.
  2. 시간 프레임에 따라 지표가 서로 확인되고 의사 결정의 정확성을 향상시킵니다.
  3. 사용자 정의 가능한 매개 변수는 다른 거래 도구에 최적화 될 수 있습니다.

위험성

  1. 부적절한 매개 변수 조정으로 인해 여러 가지 잘못된 신호가 발생할 수 있습니다.
  2. 단일 출구 지표는 가격 반전을 놓칠 수 있습니다.

최적화 제안

  1. 이동 평균과 볼링거 대역과 같은 더 많은 확인 지표를 시간 항목에 포함합니다.
  2. 반전 촛불 패턴과 같은 더 많은 출구 지표를 추가하십시오.

요약 이 전략은 VIX를 활용하여 시장 타이밍과 위험 수준을 측정하고 RSI에서 과잉 구매 / 과잉 판매 판독을 사용하여 불리한 거래를 필터링하여 적절한 순간에 입점하고 정지로 적시에 종료 할 수 있습니다. 더 넓은 시장 조건에 맞게 최적화 할 수있는 충분한 공간이 있습니다.


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

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

strategy('Vix FIX / StochRSI Strategy', overlay=true, pyramiding=9, margin_long=100, margin_short=100)

Stochlength = input.int(14, minval=1, title="lookback length of Stochastic")
StochOverBought = input.int(80, title="Stochastic overbought condition")
StochOverSold = input.int(20, title="Stochastic oversold condition")
smoothK = input(3, title="smoothing of Stochastic %K ")
smoothD = input(3, title="moving average of Stochastic %K")
k = ta.sma(ta.stoch(close, high, low, Stochlength), smoothK)
d = ta.sma(k, smoothD)

///////////// RSI 
RSIlength = input.int( 14, minval=1 , title="lookback length of RSI")
RSIOverBought = input.int( 70  , title="RSI overbought condition")
RSIOverSold = input.int( 30  , title="RSI oversold condition")
RSIprice = close
vrsi = ta.rsi(RSIprice, RSIlength)

///////////// Double strategy: RSI strategy + Stochastic strategy

pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input.float(2.0    , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50  , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
new = input(false, title="-------Text Plots Below Use Original Criteria-------" )
sbc = input(false, title="Show Text Plot if WVF WAS True and IS Now False")
sbcc = input(false, title="Show Text Plot if WVF IS True")
new2 = input(false, title="-------Text Plots Below Use FILTERED Criteria-------" )
sbcFilt = input(true, title="Show Text Plot For Filtered Entry")
sbcAggr = input(true, title="Show Text Plot For AGGRESSIVE Filtered Entry")
ltLB = input.float(40, minval=25, maxval=99, title="Long-Term Look Back Current Bar Has To Close Below This Value OR Medium Term--Default=40")
mtLB = input.float(14, minval=10, maxval=20, title="Medium-Term Look Back Current Bar Has To Close Below This Value OR Long Term--Default=14")
str = input.int(3, minval=1, maxval=9, title="Entry Price Action Strength--Close > X Bars Back---Default=3")
//Alerts Instructions and Options Below...Inputs Tab
new4 = input(false, title="-------------------------Turn On/Off ALERTS Below---------------------" )
new5 = input(false, title="----To Activate Alerts You HAVE To Check The Boxes Below For Any Alert Criteria You Want----")
sa1 = input(false, title="Show Alert WVF = True?")
sa2 = input(false, title="Show Alert WVF Was True Now False?")
sa3 = input(false, title="Show Alert WVF Filtered?")
sa4 = input(false, title="Show Alert WVF AGGRESSIVE Filter?")

//Williams Vix Fix Formula
wvf = ((ta.highest(close, pd)-low)/(ta.highest(close, pd)))*100
sDev = mult * ta.stdev(wvf, bbl)
midLine = ta.sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (ta.highest(wvf, lb)) * ph

//Filtered Bar Criteria
upRange = low > low[1] and close > high[1]
upRange_Aggr = close > close[1] and close > open[1]
//Filtered Criteria
filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh))
filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and not (wvf < upperBand and wvf < rangeHigh)

//Alerts Criteria
alert1 = wvf >= upperBand or wvf >= rangeHigh ? 1 : 0
alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh) ? 1 : 0
alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered ? 1 : 0
alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr ? 1 : 0

//Coloring Criteria of Williams Vix Fix
col = wvf >= upperBand or wvf >= rangeHigh ? color.lime : color.gray

isOverBought = (ta.crossover(k,d) and k > StochOverBought) ? 1 : 0
isOverBoughtv2 = k > StochOverBought ? 1 : 0
filteredAlert = alert3 ? 1 : 0
aggressiveAlert = alert4 ? 1 : 0


if (filteredAlert or aggressiveAlert)
    strategy.entry("Long", strategy.long)

if (isOverBought)
    strategy.close("Long")

더 많은