볼린저 밴드 전략 방향

정의

"전략 방향"은 전략이 생성할 수 있는 주문 유형을 지정합니다. 설정값이 0이면 롱과 숏이 모두 가능합니다. 설정값이 -1이면 숏만 가능하고 1이면 롱만 가능합니다. 볼린저 밴드 전략 방향은 심볼이 볼린저 밴드의 하단 밴드 아래를 교차하면 롱으로 진입하고, 심볼이 상단 밴드 위를 교차하면 숏으로 진입합니다. 하지만 전략 설정에서 방향을 매수만, 매도만 또는 둘 다로 조정할 수 있다는 점을 기억하세요.

계산

Pine Script
//@version=5
strategy("Bollinger Bands Strategy directed", overlay=true)
source = close
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)
direction = input.int(0, title = "Strategy Direction", minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
if (ta.crossover(source, lower))
    strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
else
    strategy.cancel(id="BBandLE")
if (ta.crossunder(source, upper))
    strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
else
    strategy.cancel(id="BBandSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

요약

볼린저 밴드 전략은 종목이 평균 가격에서 과도하게 확장될 가능성이 있을 때 매수 또는 매도하기 위해 만들어졌습니다. 예를 들어, 이 전략은 종목이 아래 볼린저 밴드 아래로 떨어지면 매수, 위 볼린저 밴드 위로 올라가면 매도하도록 지시할 수 있습니다. 볼린저 밴드는 종목 평균 가격의 표준 편차를 사용하여 생성되므로 일부 트레이더는 이를 평균 반전으로 간주할 수 있습니다. 이 전략은 지시형이며 설정에서 값을 제어 할 수 있습니다. 즉, 0이면 롱과 숏이 모두됩니다. 설정이 -1이면 숏만 가능하고 1이면 롱만 가능합니다.