역동적 위치 구축 전략

저자:차오장, 날짜: 2024-02-20 14:16:30
태그:

img

전반적인 설명

이 전략의 주요 아이디어는 고가 시장에서 시스템 신호에 기반한 위치를 동적으로 구축하여 위험을 통제하고 낮은 평균 입시 가격을 얻는 것입니다.

전략 논리

이 전략은 먼저 시작 자본과 DCA 비율을 설정합니다. 각 바의 종료 시, 가격 변화에 따라 조정된 비율을 계산합니다. 가격이 상승하면 비율을 낮춰줍니다. 가격이 떨어지면 비율을 증가시킵니다. 이것은 낮은 가격으로 위치에 추가 할 수 있습니다. 그 다음 조정된 비율과 남은 자본에 따라 주문 크기를 계산합니다. 각 바의 종료 시, 시작 자본이 사용 될 때까지 위치를 구축하는 명령을합니다.

따라서 리스크를 제어하고 변동적인 가격 행동 중에 낮은 평균 입시 가격을 얻을 수 있습니다. 한편, 현재 입시 상황을 판단하기 위해 평균 입시 가격과 중간 가격을 추적합니다.

이점 분석

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

  1. 지위를 동적으로 확장할 수 있고, 리스크를 제어하기 위해 다이프에 할당을 증가시키고 릴리에 할당을 감소시킵니다.

  2. 중간 가격보다 낮은 평균 입시 가격을 얻어서 더 많은 수익 잠재력을 얻을 수 있습니다.

  3. 이는 더 나은 위험/이익 비율을 위해 변동성을 가진 거품 시장에 적합합니다.

  4. 초기 자본과 DCA 비율을 미리 설정하여 포지션 사이즈 리스크를 제어할 수 있습니다.

  5. 평균 입시 가격과 중간 가격에 대한 통계를 제공하여 입시 품질을 명확하게 판단합니다.

위험 분석

또한 몇 가지 위험이 있습니다.

  1. 시장이 하락할 때, 그것은 계속 부진하여 큰 손실로 이어질 것입니다.

  2. 가격이 급격히 상승하면, 스켈링이 줄어들며, 릴리의 많은 부분을 놓칠 수도 있습니다. 다른 LSI 신호가 필요할 것입니다.

  3. 부적절 한 매개 변수 구성 은 또한 위험 을 초래 합니다. 과도 한 시작 자본 과 높은 DCA 비율 은 손실 을 증가 시킬 것입니다.

최적화 방향

전략을 최적화하는 몇 가지 방법:

  1. 많은 매출을 중단하기 위해 스톱 로스 로직을 추가합니다.

  2. 변동성 또는 다른 메트릭을 기반으로 DCA 비율을 동적으로 조정합니다.

  3. 가격 예측과 확장 결정에 대한 기계 학습 모델을 통합합니다.

  4. 다른 지표를 결합하여 시장 구조의 변화를 식별하여 출구 지점을 확장합니다.

  5. 계정 값에 기반한 동적 크기의 주문에 자본 관리 규칙을 추가합니다.

결론

이것은 매우 실용적인 동적 포지션 스케일링 전략이다. 이는 구성 가능한 매개 변수를 통해 위험을 제한하는 동시에 황소 시장에서 좋은 평균 입력을 달성하기 위해 가격 변동에 따라 포지션 크기를 유연하게 조정합니다. 다른 지표 또는 모델과 결합하면 성능을 더욱 향상시킬 수 있습니다. 장기 수익을 추구하는 투자자에게 적합합니다.


/*backtest
start: 2024-01-20 00:00:00
end: 2024-02-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RWCS_LTD

//@version=5
strategy("DCA IN Calculator {RWCS}", overlay=true, pyramiding=999, default_qty_type=strategy.cash, initial_capital=10000, commission_value=0.02)

// User inputs
backtestStartDate = input(timestamp("1 Jan 2024"), 
     title="Start Date", group="Backtest Time Period",
     tooltip="This start date is in the time zone of the exchange " + 
     "where the chart's instrument trades. It doesn't use the time " + 
     "zone of the chart or of your computer.")
start_date = true
starting_capital = input.float(defval=5000, title="Starting Capital")
dca_allocation_percentage = input.int(defval=10, title="DCA Allocation Percentage")

// Calculate DCA allocation based on price change
price_change_percentage = ((close - close[1]) / close[1]) * 100
adjusted_allocation_percentage = close > close[1] ? dca_allocation_percentage - price_change_percentage : dca_allocation_percentage + price_change_percentage // If price action is negative, increase allocations
adjusted_allocation_percentage1 = dca_allocation_percentage - price_change_percentage // If price action is positive, reduce allocations

// Calculate order size based on adjusted allocation percentage
order_size = (adjusted_allocation_percentage / 100) * starting_capital

// Track remaining capital
var remaining_capital = starting_capital

// Long on the close of every bar
if true
    // Ensure the order size doesn't exceed remaining capital or adjusted allocation
    order_size := math.min(order_size, remaining_capital, adjusted_allocation_percentage / 100 * starting_capital)
    // Ensure order size is not negative
    order_size := math.max(order_size, 0)
    
    strategy.entry("DCA", strategy.long, qty = order_size)
    remaining_capital := remaining_capital - order_size

// Plot average entry price
var float total_entry_price = 0.0
var int total_signals = 0

if start_date
    total_entry_price := total_entry_price + close
    total_signals := total_signals + 1

avg_entry_price = total_entry_price / total_signals

// Calculate and plot median price
var float median_price = na

if start_date
    var float sum_prices = 0.0
    var int num_prices = 0
    
    for i = 0 to bar_index
        if (time[i] >= backtestStartDate)
            sum_prices := sum_prices + close[i]
            num_prices := num_prices + 1
    
    median_price := sum_prices / num_prices

// Reset variables at the start of each day
if (dayofweek != dayofweek[1])
    total_entry_price := 0.0
    total_signals := 0

//table colors
borders_col = color.new(color.black, 90)
top_row_col = color.new(color.gray, 90)
size = input.string(defval='Normal', options=['Tiny', 'Small', 'Normal', 'Large'], title='Table size', inline='design', group='Table Design')
table_size = size == 'Tiny' ? size.tiny : size == 'Small' ? size.small : size == 'Normal' ? size.normal : size == 'Large' ? size.large : na

var tablee = table.new(position=position.top_right, columns=2, rows=3, frame_color=borders_col, frame_width=4, border_color=borders_col, border_width=4)

table.cell(tablee, 0, 0, "Average Entry Price", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 0, str.tostring(avg_entry_price, '#.##'), text_color=color.white, text_size=table_size)
table.cell(tablee, 0, 1, "Median Price", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 1, str.tostring(median_price, '#.##'), text_color=color.white, text_size=table_size)
table.cell(tablee, 0, 2, "Remaining Capital", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 2, str.tostring(remaining_capital, '#.##'), text_color=color.white, text_size=table_size)



더 많은