트렌딩 다바스 박스 양적 거래 전략

저자:차오장, 날짜: 2023-12-27 14:45:41
태그:

img

전반적인 설명

트렌딩 다르바스 박스 전략 (Trending Darvas Box strategy) 은 시장의 흐름을 파악하기 위해 다르바스 박스 채널을 사용하는 단기적인 거래 전략이다. 핵심 메커니즘은 시장 동력을 결정하고 거래 기회를 찾아내기 위해 다르바스 박스 지표에 의존한다. 가격이 상위 상위 상위권에 넘어가면 길게, 가격이 상하위권 아래권에 넘어가면 짧게 된다. 또한 이 전략은 안정성을 높이기 위해 다른 보조 지표를 이용한다.

전략 논리

  • 이 전략에서 기본으로 5 바인 Darvas 박스의 크기를 설정하기 위해 길이 매개 변수를 사용하십시오.
  • 높은/낮은 브레이크오웃을 기반으로 트렌드 방향을 결정하고 그에 따른 긴/단한 포지션을 취합니다.
  • 가격이 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위
  • 가격이 상자 밑으로 넘어갈 때 빨간색 BottomBox 라인이 그려집니다. 이것은 짧은 신호입니다.
  • 이동 평균 시스템을 보조 지표로 사용하십시오. 가격이 MAs보다 높을 때 길고 MAs보다 낮을 때 짧습니다.
  • RVI를 사용 하 여 과잉 구매/ 과잉 판매 구역을 식별 합니다. 신호 라인 위의 RVI는 과잉 구매를 나타냅니다. 아래의 RVI는 과잉 판매를 나타냅니다.

위의 모든 지표가 동의 할 때 엔트리가 수행됩니다. 스톱 손실은 다바스 박스의 반대 밴드에서 설정됩니다. 출구는 RVI 방향성으로 관리됩니다.

이점 분석

  • 다르바스 박스 채널은 시장 추세를 효과적으로 파악하고 놓친 기회를 줄입니다.
  • 빈번한 박스 탈출 신호, 좋은 진입 빈도
  • 합리적인 상자는 손실 설정을 멈추고 단일 거래 위험을 잘 제어합니다.
  • 보조 지표는 정확도를 높입니다.

위험 분석

  • 상자의 스톱 로스 범위가 넓고 거래당 위험도 높습니다.
  • 작은 인하가 있을 때 긴 거래는 중단될 수 있습니다.
  • 상자 방향이 항상 맞지 않아서 나쁜 신호가 될 수 있어
  • 보조 표시기가 상자와 조화를 이루기 위해 세밀한 조정이 필요합니다.

위험을 줄이기 위해 스톱 로스를 강화 할 수 있습니다. 보조 매개 변수 또한 효과적으로 신호를 스크린하기 위해 최적화가 필요합니다.

최적화 방향

  • 최적의 크기를 찾기 위해 박스 길이를 테스트합니다.
  • 보조 매개 변수를 최적화해서 박스에 가장 잘 맞게
  • 추가 신호 검증을 위해 다른 보조 지표를 시도하십시오. 예를 들어 KDJ, MACD.
  • 더 높은 안정성을 위해 손해를 멈추고 수익을 취하는 설정을 테스트하십시오.

결론

요약하자면, 트렌딩 다르바스 박스 전략은 단기 트렌드를 겨냥한 공격적인 거래 전략이다. 다르바스 박스 채널로 트렌드 변화를 빠르게 포착하며 보조 지표는 정확성을 향상시키는 데 도움이됩니다. 위험 / 보상 프로파일은이 전략에 긍정적이며 채택하고 지속적인 최적화를 가치가 있습니다.


/*backtest
start: 2023-11-26 00:00:00
end: 2023-12-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xxy_theone
// https://www.youtube.com/watch?v=YYxlnFOX9sQ
// This strategy script has been made to backtest the strategy explained in the video above


//@version=5
strategy(shorttitle = "Darvas Box Test", title="TradeIQ Darvas Box Test", overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100, currency=currency.USD)

// === INPUT BACKTEST RANGE ===
var GRP1 = "Backtest Range"
fromDate = input(timestamp("7 Mar 2022 00:00 +0000"), "From", group=GRP1)
toDate = input(timestamp("19 Mar 2022 23:59 +0000"), "To", group=GRP1)
window() =>  true


var GRP3 = "Darvas Box"
boxp=input(5, "Box Length", group=GRP3)

LL = ta.lowest(low,boxp)
k1=ta.highest(high,boxp)
k2=ta.highest(high,boxp-1)
k3=ta.highest(high,boxp-2)

NH =  ta.valuewhen(high>k1[1],high,0)
box1 =k3<k2
TopBox = ta.valuewhen(ta.barssince(high>k1[1])==boxp-2 and box1, NH, 0)
BottomBox = ta.valuewhen(ta.barssince(high>k1[1])==boxp-2 and box1, LL, 0)


plot(TopBox, linewidth=3, color=color.green, title="TBbox") 
plot(BottomBox, linewidth=3, color=color.red, title="BBbox")


var GRP4 = "MavilimW"

fmal=input(3,"First Moving Average length", group=GRP4)
smal=input(5,"Second Moving Average length", group=GRP4)
tmal=fmal+smal
Fmal=smal+tmal
Ftmal=tmal+Fmal
Smal=Fmal+Ftmal

M1= ta.wma(close, fmal)
M2= ta.wma(M1, smal)
M3= ta.wma(M2, tmal)
M4= ta.wma(M3, Fmal)
M5= ta.wma(M4, Ftmal)
MAVW= ta.wma(M5, Smal)
col1= MAVW>MAVW[1]
col3= MAVW<MAVW[1]
colorM = col1 ? color.blue : col3 ? color.red : color.yellow

plot(MAVW, color=colorM, linewidth=2, title="MAVW")


var GRP5 = "Relative Vigor Index"
len = input.int(10, title="Length", minval=1, group=GRP5)
rvi = math.sum(ta.swma(close-open), len)/math.sum(ta.swma(high-low),len)
sig = ta.swma(rvi)
offset = input.int(0, "Offset", minval = -500, maxval = 500, group=GRP5)
//plot(rvi, color=#008000, title="RVGI", offset = offset)
//plot(sig, color=#FF0000, title="Signal", offset = offset)


var longStopSet = false

long = ta.crossover(close,TopBox) and close > MAVW ? true : false
longClose = strategy.opentrades.profit(strategy.opentrades-1)>0 and ta.crossunder(rvi,sig) ? true : false
strategy.entry("Long Position", strategy.long, when = long and window() and strategy.position_size==0 and strategy.closedtrades<100)
if(longStopSet==false and strategy.position_size > 0)
    strategy.exit("exit", "Long Position", stop=BottomBox)
    longStopSet := true
if(strategy.position_size==0)
    longStopSet := false
strategy.close("Long Position", when = longClose)

var shortStopSet = false

short = ta.crossunder(close,BottomBox) and close < MAVW ? true : false
shortClose = strategy.opentrades.profit(strategy.opentrades-1)>0 and ta.crossover(rvi,sig) ? true : false
strategy.entry("Short Position", strategy.short, when = short and window() and strategy.position_size==0 and strategy.closedtrades<100)
if(shortStopSet==false and strategy.position_size < 0)
    strategy.exit("exit", "Short Position", stop=TopBox)
    shortStopSet := true
if(strategy.position_size==0)
    shortStopSet := false
strategy.close("Short Position", when = shortClose)


더 많은