컴보 백테스트 123 리버설 & 상대적인 변동성 지수

저자:차오장, 날짜: 2023-09-11 09:01:03
태그:거래기술 분석반전변동성RVI스토카스틱스튼튼한신호조합시너지위험 관리돈 관리징계

강력한 신호를 위한 역전 및 변동성 전략을 결합

이 콤보 전략은 123 역전 시스템과 상대 변동성 지수 (RVI) 를 합력하여 강력한 거래 신호를 생성합니다. 변동성 변화에 의해 확인 된 전환점을 활용하는 것을 목표로합니다.

어떻게 작동 합니까?

123 역전 전략은 잠재적인 하위와 상점을 식별합니다. 닫기가 전날보다 높고 스토카스틱이 과소매되면 긴 거리로 이동합니다. 닫기가 전날보다 낮고 스토카스틱이 과소매되면 짧은 거리로 이동합니다.

RVI는 변동성 방향을 측정합니다. 변동성이 확장되고 있거나 수축하는지 추적합니다. 전략은 30 RVI 이하로 길고 70 RVI 이상으로 짧습니다.

이 둘을 결합함으로써, 전략은 역전과 변동성 극한이 일치할 때 높은 신뢰성 엔트리를 고립하려고합니다. 신호는 정렬을 요구함으로써 추가적으로 필터링됩니다.

장점 과 단점

반전 및 변동성 전략을 혼합하면 더 강력한 신호를 제공합니다. RVI는 고갈을 확인함으로써 신뢰를 더합니다. 두 시스템을 사용하면 단일 전략에 내재된 화프사 및 잘못된 신호가 감소합니다.

그러나 어떤 시스템도 곡선 맞출 수 있다. 많은 입력을 최적화하는 것은 전략에 너무 적합할 위험이 있다. 과잉 거래를 피하기 위해 엄격한 규율이 필요하다. 신중한 위험과 돈 관리를 대체하는 전략은 없다.

전반적으로, 다양한 전략을 결합하면 신중하게 수행되면 성과를 높일 수 있습니다. 적절한 위치 크기와 위험 제한 및 인출 용도 확보는 장기적인 성공의 핵심입니다. 지속적인 검토와 유연성은 고유 한 한계점을 극복하는 데 도움이됩니다.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 08/06/2021
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The RVI is a modified form of the relative strength index (RSI). 
// The original RSI calculation separates one-day net changes into 
// positive closes and negative closes, then smoothes the data and 
// normalizes the ratio on a scale of zero to 100 as the basis for the 
// formula. The RVI uses the same basic formula but substitutes the 
// 10-day standard deviation of the closing prices for either the up 
// close or the down close. The goal is to create an indicator that 
// measures the general direction of volatility. The volatility is 
// being measured by the 10-days standard deviation of the closing prices. 
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos


RVI(Period,BuyZone, SellZone) =>
    pos = 0.0
    nU = 0.0
    nD =0.0
    xPrice = close
    StdDev = stdev(xPrice, Period)
    d = iff(close > close[1], 0, StdDev)
    u = iff(close > close[1], StdDev, 0)
    nU:= (13 * nz(nU[1],0) + u) / 14
    nD:= (13 * nz(nD[1],0) + d) / 14
    nRes = 100 * nU / (nU + nD)
    pos:= iff(nRes < BuyZone, -1,
    	   iff(nRes > SellZone, 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Relative Volatility Index", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Relative Volatility Index ----")
Period = input(10, minval=1)
BuyZone = input(30, minval=1)
SellZone = input(70, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posRVI = RVI(Period,BuyZone, SellZone)
pos = iff(posReversal123 == 1 and posRVI == 1 , 1,
	   iff(posReversal123 == -1 and posRVI == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1 ) 
    strategy.entry("Long", strategy.long)
if (possig == -1 )
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

관련

더 많은