거래 전략에 따른 부피 기반 트렌드

저자:차오장, 날짜: 2024-01-29 15:04:18
태그:

img

전반적인 설명

이것은 수정 된 볼륨 오시일레이터 지표에 기반한 트렌드 다음 거래 전략입니다. 증가하는 볼륨 신호를 식별하고 입출구를 결정하기 위해 볼륨 이동 평균을 사용합니다. 한편, 가격 오시일레이션 중에 잘못된 신호를 피하기 위해 가격 트렌드 판단을 통합합니다.

전략 논리

  1. vol_length의 길이를 가진 볼륨 이동 평균 vol_sum를 계산하고 vol_smooth 기간 이동 평균으로 평평하게 합니다.
  2. vol_sum가 임계값을 넘어서면 긴 신호를 생성하고, vol_sum가 임계값을 넘어서면 짧은 신호를 생성한다.
  3. 잘못된 신호를 필터하기 위해서는 과거 방향 바에서 확인된 가격 트렌드가 올라갔을 때만 오래 걸립니다.
  4. 두 개의 임계값 (threshold) 과 임계값 (threshold2) 를 설정합니다. 임계값은 거래 신호를 생성하고 임계값 (threshold2) 은 스톱 로스로 작용합니다.
  5. 상태 기계 로직을 통해 오픈/클로즈 오더를 관리합니다.

이점 분석

  1. 부피 지표는 더 정확한 신호를 위해 시장 구매/판매 힘의 변화를 포착합니다.
  2. 가격 추세와 결합하면 가격 변동 중에 잘못된 신호를 피합니다.
  3. 두 개의 임계 값은 위험을 더 잘 제어합니다.

위험 분석

  1. 부피 지표는 지연이 있고 가격 전환점을 놓칠 수 있습니다.
  2. 잘못된 매개 변수 설정으로 인해 거래가 너무 많거나 신호가 지연됩니다.
  3. 스톱 로즈는 거래량 상승 시 발생할 수 있습니다.

위험은 매개 변수를 조정하고 지표 계산을 최적화하고 다른 확인을 결합함으로써 완화 될 수 있습니다.

최적화 방향

  1. 시장 조건에 따른 매개 변수 최적화
  2. 더 많은 신호를 확인하기 위해 변동성 지수와 같은 다른 지표를 포함합니다.
  3. 신호의 정확성을 향상시키기 위해 기계 학습 모델을 적용하는 연구

결론

이 전략은 두 개의 스톱 로스 임계 값으로 입출을 결정하기 위해 가격 추세와 함께 향상된 볼륨 오시일레이터를 사용합니다. 이는 매개 변수 조정, 신호 필터링 및 스톱 로스 전략에서 최적화 공간을 갖는 안정적인 트렌드 다음 시스템입니다. 전반적으로 추가 연구 및 최적화에 가치가있는 실용적 가치가 있습니다.


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

//@version=4
strategy('Volume Advanced', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075, currency='USD')
startP = timestamp(input(2017, "Start Year"), input(12, "Start Month"), input(17, "Start Day"), 0, 0)
end    = timestamp(input(9999, "End Year"),   input(1, "End Month"),   input(1, "End Day"),   0, 0)
_testPeriod() =>
    iff(time >= startP and time <= end, true, false)

source = close 
vol_length  = input(34, title = "Volume - Length")
vol_smooth  = input(200,title = "Volume - Smoothing")
volriselen  = input(21,  title = "Volume - Risinglength")
volfalllen  = input(13, title = "Volume - Fallinglength")
threshold   = input(1,"threshold")
threshold2  = input(1.2,step=0.1, title="Threshold 2")
direction = input(13,"amount of bars")


volsum  = sum(volume, vol_length) / (sum(volume, vol_smooth) / (vol_smooth / vol_length))


LongEntry  = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close > close[direction]
ShortEntry = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close < close[direction]
LongExit1  = falling (volsum,volfalllen)
ShortExit1 = falling (volsum,volfalllen)
LongExit2= (crossover(volsum, threshold2) and close < close[direction])


_state = 0
_prev = nz(_state[1])
_state := _prev

if _prev == 0
    if LongEntry
        _state := 1
        _state
    if ShortEntry
        _state := 2
        _state
if _prev == 1
    if ShortEntry or LongExit1
        _state := 0
        _state
if _prev == 2
    if LongEntry or ShortExit1
        _state := 0
        _state

_bLongEntry = _state == 1 
_bLongClose = _state == 0 

long_condition = _bLongEntry and close > close[direction]
strategy.entry('BUY', strategy.long, when=long_condition)  
 
short_condition =  _bLongClose or LongExit2
strategy.close('BUY', when=short_condition)

plot(volsum,      color = color.green,    title="Vol_Sum")
plot(threshold, color = color.fuchsia, transp=50, title="Threshold")
plot(threshold2, color=color.white, transp = 50, title="Threshold 2")

더 많은