Voss 필터와 트렌드 지표에 기초한 양적 거래 전략

저자:차오장, 날짜: 2023-09-19 16:59:10
태그:

전반적인 설명

이 전략은 양적 거래의 시장에서 순환적인 전환점을 식별하기 위해 Voss 예측 필터와 Ehlers 즉각적인 트렌드 라인 지표를 결합합니다. Voss 필터는 초기 구매 / 판매 신호를 제공하며 트렌드 라인 지표는 트렌딩 시장에서 Voss 필터로부터 오해를 피하기 위해 전반적인 트렌드 방향을 결정합니다. 이 전략은 좋은 백테스트 결과로 입증 된 것처럼 순환적인 패턴을 나타내는 Bitcoin과 같은 도구에서 잘 작동합니다.

전략 논리

Voss 예측 필터

보스 필터는 존 F. 에일러스의 기사?? A Peek Into The Future?? 에서 나온다. 그 계산은 다음과 같다:

_filt = 0.5 * _s3 * _x1 + _f1 * _s2 * _filt[1] - _s1 * _filt[2] 
_voss = _x2 * _filt - _sumC

여기서 _x1은 1차 순위 가격 차이, _x2는 평형 요인, _s1, _s2, _s3는 필터 매개 변수, _f1는 사이클 매개 변수, _filt는 필터 출력, _voss는 최종 출력이다.

필터는 초기 신호를 생성하기 위해 현재와 과거의 사이클 정보를 강조하는 매끄러운 필터로 볼 수 있습니다. 고유 한 그룹 지연으로 인해 다른 지표보다 예측 신호를 생산하기 위해 미래를 바라봅니다.

즉각적인 트렌드 라인 표시기

트렌드 라인 인디케이터는 다음과 같이 계산됩니다.

_it = (_a-((_a*_a)/4.0))*_src+0.5*_a*_a*_src[1]-(_a-0.75*_a*_a)*_src[2]+2*(1-_a)*nz(_it[1])+-(1-_a)*(1-_a)*nz(_it[2]) 

이는 실시간으로 트렌드 라인을 그리며 가격 행동과 밀접하게 일치하여 트렌드 방향과 강도를 정확하게 결정합니다.

전략 논리

포스가 필터 결과를 통과하면 구매 신호가 생성됩니다.

판매 신호는 Voss가 필터 결과를 통과할 때 생성됩니다.

트렌드 라인 인디케이터에 의해 확인된 경우에만 거래 신호가 받아들여집니다. 이것은 트렌드 시장에서 Voss 필터에서 잘못된 신호를 피합니다.

장점

  • Voss 필터는 순환 회전을 잡기 위해 초기 예측 신호를 제공합니다.
  • 트렌드 라인 인디케이터는 잘못된 신호를 피하여 트렌드 방향을 정확하게 결정합니다.
  • 매개 변수는 다른 주기와 시장 환경에 최적화 될 수 있습니다.
  • 리스크를 제어하기 위해 중지가 추가될 수 있습니다.

위험 및 완화

  • 전략은 초기 신호에 의존하고, 잠재적으로 일부 경향을 놓칠 수 있습니다
  • 강한 트렌드에서 반 트렌드 신호가 발생할 수 있으며 손실을 유발할 수 있습니다.

위험은 다음과 같이 감소 할 수 있습니다.

  • 기기 사이클에 대한 최적화 기간 매개 변수
  • 잘못된 신호를 줄이기 위해 필터 대역폭을 줄이는 것
  • 강한 트렌드에 대한 신호를 피하기 위해 트렌드 필터를 추가합니다.
  • 거래 당 손실을 제어하기 위해 중지 사용

더 나은 기회

이 전략은 다음과 같이 개선될 수 있습니다.

  • 밀폐, 이동 평균 등과 같은 다른 가격 소스를 시도
  • 특정 기기 주기에 대한 필터 기간 조정
  • 더 나은 트렌드 검출을 위해 트렌드 지표 매개 변수를 최적화
  • 더 나은 조합을 위해 다른 트렌드 지표를 시도
  • 더 나은 위험 통제를 위해 정지, 후속 정지 추가
  • 가장 좋은 매개 변수 집합에 대한 매개 변수 최적화

결론

이 전략은 시장의 순환 전환을 효과적으로 식별하기 위해 Voss 필터와 트렌드 지표를 결합합니다. 최적화된 매개 변수 및 위험 통제로 강력한 양적 거래 시스템을 생성 할 수 있습니다. 좋은 백테스트 결과로 입증되는 것처럼 순환 패턴을 나타내는 도구에 널리 적용됩니다. 전반적으로 전략은 독특한 예측 기능을 가지고 있으며 다차원적 최적화를 통해 향상시킬 수있는 광범위한 잠재력을 가지고 있습니다.


/*backtest
start: 2023-08-19 00:00:00
end: 2023-09-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// A Peek Into the Future
// John F. Ehlers
// TASC Aug 2019

// Created by e2e4mfck for tradingview.com
// Modified by © Bitduke

//@version=4
//strategy("Voss Strategy (Filter + IT)", overlay=false, calc_on_every_tick=false,pyramiding=0, default_qty_type=strategy.cash,default_qty_value=1000, currency=currency.USD, initial_capital=1000,commission_type=strategy.commission.percent, commission_value=0.075)

// voss filter

source = input(close, type = input.source)
period = input(20, type = input.integer)
predict = input(4, type = input.integer)
bandwidth = input(0.25, type = input.float)

// it trendline

src = input(hl2, title="Source IT")
a = input(0.07, title="Alpha", step=0.01) 
fr = input(false, title="Fill Trend Region")
ebc = input(false, title="Enable barcolors")
hr = input(false, title="Hide Ribbon")


voss_filter (_period, _predict, _bandwidth, _source) =>
	float _filt = 0, float _sumC = 0, float _voss = 0
	_PI		= 2 * asin(1)
	_order	= 3 * _predict
	_f1		= cos(2 * _PI / _period)
	_g1		= cos(_bandwidth * 2 * _PI / _period)
	_s1		= 1 / _g1 - sqrt(1 / (_g1 * _g1) - 1)
	_s2		= 1 + _s1
	_s3		= 1 - _s1
	_x1		= _source - _source[2]
	_x2		= (3 + _order) / 2

	for _i = 0 to (_order - 1)
		_sumC := _sumC + ((_i + 1) / _order) * _voss[_order - _i]

	if bar_index <= _order
		_filt := 0		
		_voss := 0		
	else			
		_filt := 0.5 * _s3 * _x1 + _f1 * _s2 * _filt[1] - _s1 * _filt[2]
		_voss := _x2 * _filt - _sumC

	[_voss, _filt]


[Voss, Filt] = voss_filter(period, predict, bandwidth, source)


instantaneous_trendline (_src, _a, _freq, _ebc, _hr) =>
    _it = 0.0
    _it := (_a-((_a*_a)/4.0))*_src+0.5*_a*_a*_src[1]-(_a-0.75*_a*_a)*_src[2]+2*(1-_a )*nz(_it[1], ((_src+2*_src[1]+_src[2])/4.0))-(1-_a)*(1-_a)*nz(_it[2], ((_src+2*_src[1]+_src[2])/4.0))
    _lag = 2.0*_it-nz(_it[2])
    
    [_it, _lag]

[it, lag] = instantaneous_trendline(src, a, fr, ebc, hr)

// - - - - -  - - - - - //

plot(Filt, title = "Filter", style = plot.style_line, color = color.red, linewidth = 2)
plot(Voss, title = "Voss", style = plot.style_line, color = color.blue,	linewidth = 2)
hline(0.0, title = "Zero", linestyle = hline.style_dashed, color = color.black,	linewidth = 1)
plot(hr? na:it, title="IT Trend", color= fr? color.gray : color.red, linewidth=1)
plot(hr? na:lag, title="IT Trigger", color=fr? color.gray : color.blue, linewidth=1)


// Strategy Logic
longCondition =  lag < it  and crossover(Voss,Filt) 
shortCondition = it > lag and crossover(Filt,Voss) 

strategy.entry("Voss_Short", strategy.short, when=shortCondition)
strategy.entry("Voss_Long", strategy.long, when=longCondition)


// === Backtesting Dates === thanks to Trost

testPeriodSwitch = input(true, "Custom Backtesting Dates")
testStartYear = input(2019, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testStartHour = input(0, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, testStartHour, 0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(2, "Backtest Stop Month")
testStopDay = input(29, "Backtest Stop Day")
testStopHour = input(0, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, testStopHour, 0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
testPeriod_1 = testPeriod()
isPeriod = true
// === /END

if not isPeriod
    strategy.cancel_all()
    strategy.close_all()


더 많은