Bollinger 피라미딩으로 브레이크 아웃 전략

저자:차오장, 날짜: 2023-11-23 14:01:57
태그:

img

전반적인 설명

이 전략은 볼링거 밴드 (Bollinger Bands) 의 브레이크아웃을 기반으로 롱 또는 쇼트 포지션을 입력합니다. 가격이 하부 밴드 아래로 넘어갈 때 롱으로 이동하고 가격이 상부 밴드 위에 넘어갈 때 쇼트로 이동합니다. 포지션을 입력 한 후 피라미딩을 계속하고 실시간으로 스톱 로스를 업데이트합니다.

전략 논리

이 전략은 볼링거 밴드 (Bollinger Bands) 의 3개의 라인을 사용한다. 중선은 n일 이동 평균이다. 상선은 중선 + k*n일 표준편차이다. 하선은 중선 - k*n일 표준편차이다. 보통 n은 20이고 k는 2이다.

가격이 상위 라인을 넘어서면 하락 추세를 나타내고, 하락 추세를 나타내고, 하위 라인을 넘어서면 상승 추세를 나타내고, 하락 추세를 나타내고, 하락 추세를 나타냅니다.

포지션을 취한 후, 전략은 피라미딩을 계속합니다. 즉, 같은 방향으로 더 많은 포지션을 추가합니다. 피라미딩 엔트리 규칙은 가격이 초기 엔트리 후 다시 중간선을 만졌을 때입니다.

모든 포지션의 스톱 로즈는 현재 평균 보유 가격과 뱅드 가격의 차이에 따라 실시간으로 업데이트됩니다.

이점 분석

이 전략의 장점은 다음과 같습니다.

  1. 볼링거 밴드를 사용하여 브레이크오웃과 트렌드 변화를 정확하게 식별합니다.
  2. 골든 크로스와 데드 크로스 포지션을 체계적으로 입력하세요.
  3. 피라미드 건설을 통해 더 많은 수익을 얻으세요.
  4. 정지 손실을 실시간으로 업데이트하여 노크아웃을 피합니다.

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. 볼링거 밴드는 시장의 변동성에 민감하며 위프사 (whipsaws) 가 발생할 수 있습니다.
  2. 피라미딩은 노출을 증가시키고 잠재적인 손실을 유도합니다.
  3. 스톱 손실은 보장되지 않으며 여전히 스톱 손실의 확률이 있습니다.

위험 해결 방법:

  1. 다양한 사이클에 대한 볼링거 밴드 매개 변수를 최적화합니다.
  2. 피라미드 스케일과 주파수를 조정해
  3. 중간 라인을 추가로 스톱 로스 라인으로 추가합니다.

최적화 방향

전략은 아래의 측면에서 최적화 될 수 있습니다:

  1. 더 많은 시장 체제를 조정하기 위해 볼링거 밴드의 매개 변수를 최적화합니다.
  2. 피라미드 로직을 개선해서 위험과 보상을 균형 잡아야 합니다.
  3. 중간선처럼 더 많은 스톱 로스 라인을 추가합니다.
  4. 이윤을 적극적으로 확보하기 위한 이윤 취득 메커니즘을 개발해야 합니다.
  5. 다른 지표를 필터링 항목으로 결합합니다.
  6. 거래당 손실을 통제하기 위해 리스크 관리를 강화합니다.

결론

결론적으로, 이것은 전형적인 트렌드 다음 전략이다. 트렌드가 나타나면 추진력을 타고 그에 따라 수익을 창출한다. 한편, 그것은 또한 내재된 위험을 포함한다. 더 많은 시장 조건을 적응하고 윙사 위험을 해결하기 위해 추가 최적화가 필요합니다.


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

//@version=5

strategy(title='Bollinger Band strategy with split, limit, stop', shorttitle='bb strategy', overlay=true,commission_type = strategy.commission.percent, commission_value = 0.01, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, pyramiding = 4)



//Summary: Going Long or Short when Entering after Breaking the Bollinger Bands\
//At this time, the stop-loss, profit-taking price, and pyramiding standard\
// are determined from the difference between the position average price and the band price.

//After entering the position, if the price crosses the mid-band line, the stop loss is adjusted to the mid-band line.



//each trade, entry position size = 10% of total cash
//max pyramiding is 4
//commission = 0.01%





in_period = true


bb_length = input.int(20)
bb_mult = input.int(2)

[middle, upper, lower] = ta.bb(close,bb_length, bb_mult)
plot(middle, color=color.aqua)
plot(upper, color=color.orange)
plot(lower, color=color.orange)
long_cond = ta.crossover(close,lower)
short_cond = ta.crossunder(close,upper)

var saved_ph = 0.0
if strategy.opentrades>0 and strategy.opentrades[1]==0 and strategy.position_size > 0
    saved_ph := upper[1]
var saved_pl = 0.0
if strategy.opentrades>0 and strategy.opentrades[1]==0 and strategy.position_size < 0
    saved_pl := lower[1]

avg = strategy.position_avg_price

long_diff = saved_ph-avg
short_diff = saved_pl-avg

long_stoploss = avg - 1*long_diff
short_stoploss = avg - 1*short_diff

long_avgdown = avg - 0.5*long_diff
short_avgup = avg - 0.5*short_diff

long_profit_price = avg + 0.5*long_diff
short_profit_price = avg + 0.5*short_diff

var label _label = na
if in_period
    if long_cond and strategy.opentrades==0
        strategy.entry("Long",strategy.long)
    if long_cond and strategy.opentrades >0 and (close[1]<long_avgdown or close[2]<long_avgdown)
        strategy.entry("Long",strategy.long)

    if short_cond and strategy.opentrades==0
        strategy.entry("Short", strategy.short)
    if short_cond and strategy.opentrades>0 and (close[1]>short_avgup or close[2]>short_avgup)
        strategy.entry("Short",strategy.short)

plot(avg, style=plot.style_linebr)


plot(strategy.position_size > 0? long_profit_price: na,color=color.green, style=plot.style_linebr)
plot(strategy.position_size > 0? long_avgdown: na,color=color.yellow, style=plot.style_linebr)
plot(strategy.position_size > 0? long_stoploss: na,color=color.red, style=plot.style_linebr)

plot(strategy.position_size < 0? short_profit_price: na,color=color.green, style=plot.style_linebr)
plot(strategy.position_size < 0? short_avgup: na,color=color.yellow, style=plot.style_linebr)
plot(strategy.position_size < 0? short_stoploss: na,color=color.red, style=plot.style_linebr)

if strategy.position_size > 0
    if ta.crossover(close, middle)
        strategy.exit("Long Exit", "Long", limit=long_profit_price, stop=middle)
    else
        strategy.exit("Long Exit", "Long", limit=long_profit_price, stop=long_stoploss)
if strategy.position_size < 0
    if ta.crossunder(close, middle)
        strategy.exit("Short Exit", "Short", limit=short_profit_price, stop=middle)
    else
        strategy.exit("Short Exit", "Short", limit=short_profit_price, stop=short_stoploss)

더 많은