이동평균선과 변동성을 기반으로 한 추세추종 전략


생성 날짜: 2023-09-21 21:32:40 마지막으로 수정됨: 2023-09-21 21:32:40
복사: 0 클릭수: 658
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 평균선, 브린 밴드 및 시간 분량과 같은 여러 지표를 종합적으로 사용하여 가격 트렌드의 시작과 끝을 식별하고 트렌드 추적 작업을 수행합니다. 전략은 여러 지표를 통해 확인하여 가짜 돌파구를 효과적으로 필터링 할 수 있습니다.

전략 원칙

이 전략은 다음과 같은 중요한 단계를 포함합니다.

  1. 빠른 평균선과 느린 평균선을 계산한다. 평균선 계산은 VWAP를 사용해서 종식 가격보다는 실제 거래 가격을 더 정확하게 반영한다.

  2. 평균 선의 평균값을 계산하고 그 평균값을 바탕으로 브린 밴드를 그리는 것. 브린 밴드는 가격 변동률이 확대되었는지 판단하고 트렌드를 시작하도록 지시한다.

  3. 트레이딩의 양이 증가하고 있는지 확인하기 위해 TSV (Time Scale Volume) 를 도입하여 트렌드를 확인한다.

  4. 빠른 평균 선에서 느린 평균 선을 통과하면, 가격이 부린 상반선보다 높고 TSV가 0보다 크면, 구매 신호가 발생한다. 반대로 판매 신호가 발생한다.

  5. 평균선 회수와 부린 하차를 사용해서 손해 평정지 신호로 다.

전략적 이점

  • 다양한 지표를 사용하여 확인하여 가짜 돌파구를 효과적으로 필터링하고 트렌드를 식별합니다.

  • 평균선 계산 방법은 실제 거래 가격을 더 정확하게 반영할 수 있습니다.

  • 변동률 지표와 결합하여 추세가 존재하는지 여부

  • 거래량 지표의 증가, 트렌드 개발의 확인

  • 합리적인 스톱 및 스톱 기준을 설정하여 위험을 통제하십시오.

  • 파라미터는 최적의 상태로 조정할 수 있습니다

전략적 위험

  • 다중 지표 조합 판단, 파라미터 최적화가 어려운 문제

  • 평균선과 브린 벨트 모두 지연 문제로 인해 적당한 시간 내에 중단되지 않을 수 있습니다.

  • 시간 분량 지표는 매개 변수 설정에 민감하며 시장에 따라 조정해야 합니다.

  • 시장에서 더 많은 잘못된 신호가 발생할 가능성이 있습니다.

  • 거래 비용의 영향을 고려하지 않고 실제 적자는 재검토 결과보다 낮습니다.

전략 최적화 방향

  • 기계학습을 사용하여 변수 집합을 자동으로 최적화하십시오.

  • 다이내믹 모블 스톱 또는 스톱 트래킹을 설정하여 수익을 더 잘 고정합니다.

  • 거래량 에너지 지표를 도입하여 거래량에서 벗어날 수 있는 잘못된 거래를 방지합니다.

  • 파동 이론과 결합하여, 현재 트렌드의 초기, 중, 후기에 있다고 판단하고, 동적으로 조정하는 전략 파라미트

  • 실제 거래 비용의 영향을 고려하고, 비용 효율성을 제어하기 위해 최소 스톱 마피트를 설정합니다.

요약하다

이 전략은 다양한 지표를 종합적으로 고려하여 트렌드 식별 능력을 제공하여 실제 트렌드의 시작과 끝을 효과적으로 판단할 수 있습니다. 변수 최적화, 스톱 로즈 최적화 및 필터 최적화를 통해 전략의 안정성을 더욱 향상시킬 수 있습니다. 그러나 전체적으로, 트렌드 추적 전략으로서, 그 회수 및 손실 비율은 여전히 일정 위험을 감수해야합니다. 거래자는 기회를 기다리며 엄격한 위험 관리 의식이 필요합니다.

전략 소스 코드
/*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)