하락 추세 전략 후 달러 가격 평균화

저자:차오장, 날짜: 2024-01-17 17:57:58
태그:

img

전반적인 설명

이 전략의 주요 아이디어는 단기 하락이 끝나면 정기적으로 낮은 평균 가격을 추적하는 것입니다. 구체적으로 전략은 매월 말 단기 하락의 끝을 식별하여 정기적으로 포지션을 추가 할 것입니다. 동시에 마지막 K 라인이 닫을 때 포지션을 정리합니다.

전략 원칙

  1. 정규 추적 신호 판단: 24*30 K 라인 (한 달을 나타내는) 후에 정규 추적 지점이 도달되었다고 결정되고 첫 번째 신호가 출력됩니다.

  2. 단기 하락 판단의 끝: 추세를 결정하기 위해 MACD 지표를 사용하십시오. MACD 이차가 발생하고 MACD가 신호 라인 아래로 갈 때 단기 하락이 끝났다고 결정됩니다.

  3. 진입 규칙: 정규 추적 신호와 단기 하락 신호가 동시에 작동하면 추적 신호가 방출되고 긴 포지션이 열립니다.

  4. 출구 규칙: 마지막 K 라인이 닫히면 모든 위치를 비워

위는 전략의 기본 거래 흐름과 원칙입니다. 전략은 백테스트에서 월 1,000 달러를 추적하도록 기본 설정되어 있으며, 33 개월으로 확장 될 것입니다. 즉 총 투자액은 33,000 달러입니다.

이점 분석

이 전략의 가장 큰 장점은 낮은 수준에서 정기적으로 포지션을 구축 할 수 있다는 것입니다. 장기적 관점에서 높은 수익을 창출하기 위해 상대적으로 저렴한 평균 비용 가격을 얻을 수 있습니다. 또한, 단기 구매 지점을 식별하기 위해 MACD 지표를 사용하는 것은 또한 상당히 신뢰할 수 있고 명확합니다. 이는 어느 정도 교착상태에 빠지는 것을 피할 수 있으며 손실도 어느 정도 피할 수 있습니다.

일반적으로 이것은 비용 평균화 전략으로 중장기 보유자가 만족스러운 수익을 얻기 위해 정기적으로 조를 구매하는 데 더 적합합니다.

위험 과 해결책

전략의 주요 위험은 단기 하락의 끝을 정확하게 결정할 수 없다는 것입니다. 하락의 끝에 대한 MACD 지표의 판단은 지연 될 수 있습니다. 이는 최적의 지점에 진입하지 못하게 할 것입니다. 또한, 자금의 분산 투자는 운영 비용을 증가시킵니다.

볼링거 밴드, KDJ 등과 같은 트렌드를 결정하기 위해 더 많은 지표를 추가하는 것을 고려하십시오. 이러한 지표는 반전 시기를 사전에 예측 할 수 있습니다. 동시에 매월 투자되는 자금액은 수익에 대한 운영 비용의 영향을 줄이기 위해 최적화 될 수 있습니다.

최적화 방향

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

  1. 매 2개월에 한 번 추적하는 것과 같은 정기적인 추적 주기를 최적화하여 과도한 빈번한 거래 문제를 줄이십시오.

  2. 단기적 하락의 끝을 결정하기 위해 더 많은 지표를 포함시켜 입점점을 가장 낮은 지점으로 가깝게 만듭니다.

  3. 최적의 구성을 찾기 위해 매달 투자하는 자금액을 최적화하십시오.

  4. 가격이 너무 낮아지면 과도한 손실을 피하기 위해 손해를 막는 전략을 적용하려고 노력하십시오.

  5. 최적의 보유일을 찾기 위해 다른 보유 기간의 수익에 대한 영향을 테스트합니다.

요약

하락 추세 전략에 따른 달러 비용 평균화의 전반적인 아이디어는 명확하고 이해하기 쉽습니다. 정기적인 보충과 단기 판단을 결합함으로써 더 저렴한 평균 비용 가격을 얻을 수 있습니다. 이 전략의 중장기 보유는 안정적인 수익을 창출 할 수 있으며 장기 투자 가치를 추구하는 투자자에게 적합합니다. 동시에 성능이 한 단계 올라갈 수 있도록 전략을 더 향상시키기 위해 최적화 할 수있는 몇 가지 방향이 있습니다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
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/
// © BHD_Trade_Bot

// @version=5
strategy(
 shorttitle            = 'DCA After Downtrend v2',
 title                 = 'DCA After Downtrend v2 (by BHD_Trade_Bot)',
 overlay               = true,
 calc_on_every_tick    = false,
 calc_on_order_fills   = false,
 use_bar_magnifier     = false,
 pyramiding            = 1000,
 initial_capital       = 0,
 default_qty_type      = strategy.cash,
 default_qty_value     = 1000,
 commission_type       = strategy.commission.percent,
 commission_value      = 1.1)



// Backtest Time Period
start_year   = input(title='Start year'   ,defval=2017)
start_month  = input(title='Start month'  ,defval=1)
start_day    = input(title='Start day'    ,defval=1)
start_time   = timestamp(start_year, start_month, start_day, 00, 00)

end_year     = input(title='end year'     ,defval=2050)
end_month    = input(title='end month'    ,defval=1)
end_day      = input(title='end day'      ,defval=1)
end_time     = timestamp(end_year, end_month, end_day, 23, 59)

window() => time >= start_time and time <= end_time ? true : false
h1_last_bar = (math.min(end_time, timenow) - time)/1000/60/60 < 2



// EMA
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)

// EMA_CD
emacd = ema50 - ema200
emacd_signal = ta.ema(emacd, 20)
hist = emacd - emacd_signal

// BHD Unit
bhd_unit = ta.rma(high - low, 200) * 2
bhd_upper = ema200 + bhd_unit
bhd_upper2 = ema200 + bhd_unit * 2
bhd_upper3 = ema200 + bhd_unit * 3
bhd_upper4 = ema200 + bhd_unit * 4
bhd_upper5 = ema200 + bhd_unit * 5

bhd_lower = ema200 - bhd_unit
bhd_lower2 = ema200 - bhd_unit * 2
bhd_lower3 = ema200 - bhd_unit * 3
bhd_lower4 = ema200 - bhd_unit * 4
bhd_lower5 = ema200 - bhd_unit * 5

// Count n candles after x long entries
var int nPastCandles = 0
var int entryNumber = 0
if window()
    nPastCandles := nPastCandles + 1



// ENTRY CONDITIONS

// 24 * 30 per month
entry_condition1 = nPastCandles > entryNumber * 24 * 30

// End of downtrend
entry_condition2 = emacd < 0 and hist < 0 and hist > hist[2]

ENTRY_CONDITIONS = entry_condition1 and entry_condition2


if ENTRY_CONDITIONS
    entryNumber := entryNumber + 1
    entryId = 'Long ' + str.tostring(entryNumber)
    strategy.entry(entryId, strategy.long)
    
    

// CLOSE CONDITIONS

// Last bar
CLOSE_CONDITIONS = barstate.islast or h1_last_bar

if CLOSE_CONDITIONS
    strategy.close_all()



// Draw
colorRange(src) =>
    if src > bhd_upper5
        color.rgb(255,0,0)
    else if src > bhd_upper4
        color.rgb(255,150,0)
    else if src > bhd_upper3
        color.rgb(255,200,0)
    else if src > bhd_upper2
        color.rgb(100,255,0)
    else if src > bhd_upper
        color.rgb(0,255,100)
    else if src > ema200
        color.rgb(0,255,150)
    else if src > bhd_lower
        color.rgb(0,200,255)
    else if src > bhd_lower2
        color.rgb(0,150,255)
    else if src > bhd_lower3
        color.rgb(0,100,255)
    else if src > bhd_lower4
        color.rgb(0,50,255)
    else
        color.rgb(0,0,255)
        
bhd_upper_line = plot(bhd_upper, color=color.new(color.teal, 90))
bhd_upper_line2 = plot(bhd_upper2, color=color.new(color.teal, 90))
bhd_upper_line3 = plot(bhd_upper3, color=color.new(color.teal, 90))
bhd_upper_line4 = plot(bhd_upper4, color=color.new(color.teal, 90))
bhd_upper_line5 = plot(bhd_upper5, color=color.new(color.teal, 90))

bhd_lower_line = plot(bhd_lower, color=color.new(color.teal, 90))
bhd_lower_line2 = plot(bhd_lower2, color=color.new(color.teal, 90))
bhd_lower_line3 = plot(bhd_lower3, color=color.new(color.teal, 90))
bhd_lower_line4 = plot(bhd_lower4, color=color.new(color.teal, 90))
bhd_lower_line5 = plot(bhd_lower5, color=color.new(color.teal, 90))
// fill(bhd_upper_line5, bhd_lower_line5, color=color.new(color.teal, 95))

plot(ema50, color=color.orange, linewidth=3)
plot(ema200, color=color.teal, linewidth=3)
plot(close, color=color.teal, linewidth=1)
plot(close, color=colorRange(close), linewidth=3, style=plot.style_circles)


더 많은