더블 바텀 반전 이동 평균 DCA 그리드 전략


생성 날짜: 2024-02-20 11:09:33 마지막으로 수정됨: 2024-02-20 11:09:33
복사: 3 클릭수: 839
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

더블 바텀 반전 이동 평균 DCA 그리드 전략

개요

이중 하위 반전 평균 DCA 격자 전략은 주로 평행 가격 반전과 DCA 전략을 구현하는 격자 단계적 입장을 적용한다. 그것은 이중 하위 반전 형태에 따라 반전 기회를 판단한다. 반전 형태가 촉발되면 여러 개의 다른 가격의 주문서를 사용하여 DCA와 결합하여 단계적 격자 입장을 구축한다.

전략 원칙

이 전략은 먼저 K선에서 2개의 연속적인 종료 가격과 같은 바닥이 나타나는지 판단합니다. 이것은 ?? 이중 바닥 ?? 이라고 불립니다. 이중 바닥이 검출되면, 가격 반전의 기회가 있을 수 있다고 생각됩니다. 이 때, 전략은 바닥 근처에 여러 개의 제한 가격 주문을 설정합니다. 이 주문의 가격은 ATR 및 변동률에 따라 계산되어 격자 영역을 형성합니다. 이것은 DCA의 효과를 실현합니다.

구체적으로, 먼저 ta.atr을 통해 가장 최근의 14개의 K선에 대한 ATR 지표를 계산하고, 그 다음 가장 최근의 5개의 K선과 결합하여 가격 변동률을 계산하는 것이 격자 간을 결정하는 데 사용되는 주요 파라미터이다. 격자 간은 4개의 가격점으로 나뉘어져 있으며, 각각 밑바닥 가격 + 변동률, 밑바닥 가격 + 0.75배의 변동률 등으로 나뉘어 있다. 이중 밑바닥 조건을 유발한 후, 이 계산 공식에 따라 해당 가격에 대해 4개의 제한 가격 주문을 설정하고, 각 주문의 수를 동일하게 한다. 매매되지 않은 단은 설정된 경량 후 자동으로 주문을 철회한다.

또한, 전략은 스톱로스 레벨과 스톱 포스 레벨을 설정한다. 스톱 포스 가격은 이중 바닥의 최저 가격-최소한 점프 레벨이며, 스톱 포스 가격은 입문 가격+ATR 지표의 5배이다. 포지션 레벨이 0이 아닌 경우, 두 가지 가격은 실시간으로 업데이트된다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 이중 바닥을 사용하여 역전 시점을 판단하면 가짜 돌파구를 효과적으로 피할 수 있다.
  2. DCA 격자 설계는 거래자가 다른 가격으로 단계적으로 포지션을 구축하여 포지션 비용을 절감할 수 있도록 해줍니다.
  3. ATR 및 변동률 파라미트는 시장 변화에 적응하기 위해 격자 및 정지 공간을 동적으로 조정할 수 있다.
  4. 자동 손실 제도는 개별 손실을 효과적으로 제어 할 수 있습니다.

위험 분석

주요 위험은 다음과 같습니다.

  1. 가격이 반전하지 않고, 이중 하위 지원 지점 (double bottom support) 을 넘어설 수도 있다. 이 시점에서는 스톱로스가 트리거되어 손실이 발생한다. 스톱로스 거리를 적절히 늘릴 수 있다.
  2. DCA 격자 구간이 잘못 설정되어 대부분의 임원이 거래할 수 없습니다. 다른 매개 변수를 테스트하여 거래율을 보장 할 수 있습니다.
  3. 시장의 격렬한 흔들림이 있을 때, 정지기는 자주 유발될 수 있다. 정지배수를 적절히 확장하는 것을 고려할 수 있다.

최적화 방향

이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.

  1. 트렌드 판단을 높이고, 트렌드 중 하나만 볼 때 반전 조작을 하고, 큰 트렌드를 놓치지 않도록 한다.
  2. 첫 번째 단위 포지션을 늘리고, 그라이트 포지션을 점차 줄이고, 자금 사용 효율을 최적화하십시오.
  3. 다양한 변수 조합을 테스트하여 최적의 변수를 찾습니다. 또한 시장에 따라 실시간으로 조정되는 동적 변수를 설계 할 수 있습니다.
  4. 고급 플랫폼에서 기계 학습을 통합하여 매개 변수의 자동 최적화를 구현할 수 있다.

요약하다

이중 하단 반전 평행 DCA 격자 전략은 가격 형태, 평행 지표, 격자 거래 등 여러 가지 기술적 수단을 종합적으로 사용한다. 판단 시점 정밀, 비용 제어, 철회 보호 등의 장점이 있다. 이 전략의 최적화 공간은 여전히 넓고, 깊이 있는 연구와 응용에 가치가 있다. 매개 변수가 적절하게 조정되면, 변동 상황에서도 좋은 효과를 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2024-02-12 00:00:00
end: 2024-02-19 00:00:00
period: 3m
basePeriod: 1m
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/
// © cherepanovvsb

//@version=5
strategy("Reversal (only long)", overlay=true, margin_long=1, margin_short=1,initial_capital=1000,commission_type = strategy.commission.percent,commission_value =0.1,currency='USD', process_orders_on_close=true)
plotshape(low == low[1], style=shape.triangleup, location=location.belowbar, color=color.blue, title="1 Setup")
plotshape(low == low[1] and low[1]==low[2], style=shape.triangleup, location=location.belowbar, color=color.red, title="Triple Setup")

ATRlenght   = input.int(title="ATR length for taking profit", defval=14, group="Strategy Settings")
rewardMultiplier= input.int(title="ATR multiplier", defval=5, group="Strategy Settings")
Volatility_length=input.int(title='Volatility length',defval=5,group="Strategy Settings")
Volatility_multiplier=input.float(title='Volatility multiplier',defval=0.5,step=0.1, group="Strategy Settings")
Candles_to_wait=input.int(title='How many candles to wait after placing orders grid?',defval=4,group="Strategy Settings")

// Get ATR
atr1 = ta.atr(ATRlenght)

//Get volatility values (not ATR) 
float result = 0
for i = 0 to Volatility_length
	result+=high[i]-low[i]
volatility=result*Volatility_multiplier/Volatility_length

//Validate entrance points
validlow =  low [2]== low[1] and not na(atr1) 
validlong = validlow and strategy.position_size == 0  and low[1]<low


// Calculate SL/TP
longStopPrice = low[1]-syminfo.mintick
longStopDistance = close - longStopPrice
longTargetPrice = close + (longStopDistance * rewardMultiplier)
strategy.initial_capital = 50000
//Assign all variables
var tradeStopPrice = 0.0
var tradeTargetPrice = 0.0
var point1=0.0
var point2=0.0
var point3=0.0
var point4=0.0
var contracts = int(strategy.initial_capital/close)/4
if validlong 
    tradeStopPrice := longStopPrice
    tradeTargetPrice := longTargetPrice
    point1:=low[1]+volatility
    point2:=low[1]+volatility*0.75
    point3:=low[1]+volatility*0.5
    point4:=low[1]+volatility*0.25

strategy.entry ("Long1", strategy.long,limit=point1,qty=contracts, when=validlong)
strategy.entry ("Long2", strategy.long,limit=point2,qty=contracts, when=validlong)
strategy.entry ("Long3", strategy.long,limit=point3,qty=contracts, when=validlong)
strategy.entry ("Long4", strategy.long,limit=point4,qty=contracts, when=validlong)

stopcondition = ta.barssince(validlong) == Candles_to_wait

strategy.cancel("Long1",when=stopcondition)
strategy.cancel("Long2",when=stopcondition)
strategy.cancel("Long3",when=stopcondition)
strategy.cancel("Long4",when=stopcondition)
    
strategy.exit(id="Long Exit", limit=tradeTargetPrice, stop=tradeStopPrice, when=strategy.position_size > 0)

plot(strategy.position_size != 0 or validlong ? tradeStopPrice : na, title="Trade Stop Price", color=color.red, style=plot.style_linebr, linewidth=3)
plot(strategy.position_size != 0 or validlong ? tradeTargetPrice : na, title="Trade Target Price", color=color.green, style=plot.style_linebr, linewidth=3)

plot(strategy.position_size != 0? point1 : na, title="Long1", color=color.green, style=plot.style_linebr, transp=0)
plot(strategy.position_size != 0? point2 : na, title="Long2", color=color.green, style=plot.style_linebr, transp=0)
plot(strategy.position_size != 0? point3 : na, title="Long3", color=color.green, style=plot.style_linebr, transp=0)
plot(strategy.position_size != 0? point4 : na, title="Long4", color=color.green, style=plot.style_linebr, transp=0)