양량 가중된 평균 가격과 변동성에 기초한 전략에 따른 경향

저자:차오장, 날짜: 2023-09-21 21:32:40
태그:

전반적인 설명

이 전략은 부피 가중된 평균 가격, 볼링거 밴드 및 시간 세그먼트 된 부피를 포함한 여러 지표를 통합하여 가격 트렌드의 시작과 끝을 식별하고 트렌드를 따라갑니다. 여러 확인은 잘못된 브레이크를 효과적으로 필터 할 수 있습니다.

전략 논리

이 전략은 다음의 주요 단계를 포함합니다.

  1. 빠른 및 느린 볼륨 가중 된 평균 가격 라인을 계산합니다. 실제 거래 가격을 더 잘 반영하기 위해 폐쇄 가격 대신 VWAP가 사용됩니다.

  2. 볼링거 밴드를 그리기 위해 VWAP 라인의 평균을 가져보세요. 밴드들에 의해 보이는 변동성이 확대되는 것은 트렌드 시작을 시사합니다.

  3. 거래량 증가와 트렌드를 확인하기 위해 시간 세그먼트 된 볼륨 (TSV) 을 도입하십시오.

  4. 빠른 VWAP가 느린 VWAP를 넘어서면 구매 신호를 생성하고, 가격이 볼링거 상단보다 떨어지면 TSV가 양수입니다. 역전이 발생하면 판매 신호를 생성합니다.

  5. VWAP pullback 및 Bollinger 하위 대역을 Stop Loss 신호로 사용하세요.

장점

  • 다수의 확인은 거짓 브레이크를 효과적으로 필터하고 트렌드 시작을 식별합니다.

  • VWAP 계산은 실제 거래 가격을 더 잘 반영합니다.

  • 변동성 지표는 추세가 있는지 여부를 판단합니다.

  • 거래량은 추세의 지속을 확인

  • 적당한 스톱 로스 및 영업 영업 통제 위험

  • 구성 가능한 매개 변수는 유연한 최적화를 허용

위험성

  • 여러 지표를 최적화하는 데 어려움이 있습니다.

  • VWAP와 볼링거 밴드의 지연성 (lagging nature)

  • 다른 시장에 대한 매개 변수 조정에 민감한 TSV

  • 범위에 묶인 시장에서 더 많은 잘못된 신호

  • 거래 비용을 무시하고, 실제 P&L는 백테스트보다 약합니다.

개선

  • 매개 변수 조합을 자동으로 최적화하는 기계 학습을 적용

  • 이윤을 더 잘 확보하기 위해 동적 또는 후속 스톱 손실을 설정

  • 분리를 피하기 위해 부피 운동량 지표를 추가합니다.

  • 트렌드 단계를 결정하기 위해 엘리엇 파도를 통합, 그에 따라 매개 변수를 조정

  • 거래 비용을 고려하고 비용 효율을 제어하기 위해 최소 수익 목표를 설정

결론

이 전략은 여러 지표를 통합하여 좋은 트렌드 식별을 제공합니다. 실제 트렌드의 시작과 끝을 효과적으로 결정할 수 있습니다. 매개 변수 최적화, 스톱 로스 최적화 및 필터 최적화로 안정성의 추가 개선이 달성 될 수 있습니다. 그러나 전반적으로, 트렌드 다음 전략으로, 여전히 특정 수준의 마감 및 위험 보상 비율을 가지고 있습니다. 거래자는 기회를 기다리기 위해 인내심과 엄격한 위험 관리 사고방식을 필요로합니다.


/*backtest
start: 2022-09-14 00:00:00
end: 2023-09-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @version=4

// Credits

// "Vwap with period" code which used in this strategy to calculate the leadLine was written by "neolao" active on https://tr.tradingview.com/u/neolao/
// "TSV" code which used in this strategy was written by "liw0" active on https://www.tradingview.com/u/liw0. The code is corrected by "vitelot" December 2018.

strategy("HYE Trend Hunter [Strategy]", overlay = true, initial_capital = 1000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_value = 0.025, pyramiding = 0)
  
// Strategy inputs 

slowtenkansenPeriod = input(9, minval=1, title="Slow Tenkan Sen VWAP Line Length", group = "Tenkansen / Kijunsen")
slowkijunsenPeriod = input(26, minval=1, title="Slow Kijun Sen VWAP Line Length", group = "Tenkansen / Kijunsen")
fasttenkansenPeriod = input(5, minval=1, title="Fast Tenkan Sen VWAP Line Length", group = "Tenkansen / Kijunsen")
fastkijunsenPeriod = input(13, minval=1, title="Fast Kijun Sen VWAP Line Length", group = "Tenkansen / Kijunsen")
BBlength = input(20, minval=1, title= "Bollinger Band Length", group = "Bollinger Bands")
BBmult = input(2.0, minval=0.001, maxval=50, title="Bollinger Band StdDev", group = "Bollinger Bands")
tsvlength  = input(13, minval=1, title="TSV Length", group = "Tıme Segmented Volume")
tsvemaperiod = input(7, minval=1, title="TSV Ema Length", group = "Tıme Segmented Volume")

// Make input options that configure backtest date range  
 
startDate = input(title="Start Date", type=input.integer,
     defval=1, minval=1, maxval=31, group = "Backtest Range")
startMonth = input(title="Start Month", type=input.integer,
     defval=1, minval=1, maxval=12, group = "Backtest Range")
startYear = input(title="Start Year", type=input.integer,
     defval=2000, minval=1800, maxval=2100, group = "Backtest Range")

endDate = input(title="End Date", type=input.integer, 
     defval=31, minval=1, maxval=31, group = "Backtest Range")
endMonth = input(title="End Month", type=input.integer,
     defval=12, minval=1, maxval=12, group = "Backtest Range") 
endYear = input(title="End Year", type=input.integer,
     defval=2021, minval=1800, maxval=2100, group = "Backtest Range")
     
inDateRange =  true

//Slow Tenkan Sen Calculation

typicalPriceTS = (high + low + close) / 3
typicalPriceVolumeTS = typicalPriceTS * volume
cumulativeTypicalPriceVolumeTS = sum(typicalPriceVolumeTS, slowtenkansenPeriod)
cumulativeVolumeTS = sum(volume, slowtenkansenPeriod)
slowtenkansenvwapValue = cumulativeTypicalPriceVolumeTS / cumulativeVolumeTS

//Slow Kijun Sen Calculation

typicalPriceKS = (high + low + close) / 3
typicalPriceVolumeKS = typicalPriceKS * volume
cumulativeTypicalPriceVolumeKS = sum(typicalPriceVolumeKS, slowkijunsenPeriod)
cumulativeVolumeKS = sum(volume, slowkijunsenPeriod)
slowkijunsenvwapValue = cumulativeTypicalPriceVolumeKS / cumulativeVolumeKS

//Fast Tenkan Sen Calculation

typicalPriceTF = (high + low + close) / 3
typicalPriceVolumeTF = typicalPriceTF * volume
cumulativeTypicalPriceVolumeTF = sum(typicalPriceVolumeTF, fasttenkansenPeriod)
cumulativeVolumeTF = sum(volume, fasttenkansenPeriod)
fasttenkansenvwapValue = cumulativeTypicalPriceVolumeTF / cumulativeVolumeTF

//Fast Kijun Sen Calculation

typicalPriceKF = (high + low + close) / 3
typicalPriceVolumeKF = typicalPriceKS * volume
cumulativeTypicalPriceVolumeKF = sum(typicalPriceVolumeKF, fastkijunsenPeriod)
cumulativeVolumeKF = sum(volume, fastkijunsenPeriod)
fastkijunsenvwapValue = cumulativeTypicalPriceVolumeKF / cumulativeVolumeKF

//Slow LeadLine Calculation
 
lowesttenkansen_s = lowest(slowtenkansenvwapValue, slowtenkansenPeriod)
highesttenkansen_s = highest(slowtenkansenvwapValue, slowtenkansenPeriod)

lowestkijunsen_s = lowest(slowkijunsenvwapValue, slowkijunsenPeriod)
highestkijunsen_s = highest(slowkijunsenvwapValue, slowkijunsenPeriod)

slowtenkansen = avg(lowesttenkansen_s, highesttenkansen_s)
slowkijunsen = avg(lowestkijunsen_s, highestkijunsen_s)
slowleadLine = avg(slowtenkansen, slowkijunsen)

//Fast LeadLine Calculation
 
lowesttenkansen_f = lowest(fasttenkansenvwapValue, fasttenkansenPeriod)
highesttenkansen_f = highest(fasttenkansenvwapValue, fasttenkansenPeriod)

lowestkijunsen_f = lowest(fastkijunsenvwapValue, fastkijunsenPeriod)
highestkijunsen_f = highest(fastkijunsenvwapValue, fastkijunsenPeriod)

fasttenkansen = avg(lowesttenkansen_f, highesttenkansen_f)
fastkijunsen = avg(lowestkijunsen_f, highestkijunsen_f)
fastleadLine = avg(fasttenkansen, fastkijunsen)

// BBleadLine Calculation

BBleadLine = avg(fastleadLine, slowleadLine)

// Bollinger Band Calculation
 
basis = sma(BBleadLine, BBlength)
dev = BBmult * stdev(BBleadLine, BBlength)
upper = basis + dev
lower = basis - dev

// TSV Calculation

tsv = sum(close>close[1]?volume*(close-close[1]):close<close[1]?volume*(close-close[1]):0,tsvlength)
tsvema = ema(tsv, tsvemaperiod)

// Rules for Entry & Exit  

if(fastleadLine > fastleadLine[1] and slowleadLine > slowleadLine[1] and tsv > 0 and tsv > tsvema and close > upper and inDateRange)
    strategy.entry("BUY", strategy.long)
 
if(fastleadLine < fastleadLine[1] and slowleadLine < slowleadLine[1])
    strategy.close("BUY")

// Plots 

colorsettingS = input(title="Solid Color Slow Leadline", defval=false, type=input.bool)
plot(slowleadLine, title = "Slow LeadLine", color = colorsettingS ? color.aqua : slowleadLine > slowleadLine[1] ? color.green : color.red, linewidth=3)

colorsettingF = input(title="Solid Color Fast Leadline", defval=false, type=input.bool)
plot(fastleadLine, title = "Fast LeadLine", color = colorsettingF ? color.orange : fastleadLine > fastleadLine[1] ? color.green : color.red, linewidth=3)

p1 = plot(upper, "Upper BB", color=#2962FF)
p2 = plot(lower, "Lower BB", color=#2962FF)
fill(p1, p2, title = "Background", color=color.blue)

더 많은