가격 돌파구 볼링거 밴드 A 전략

저자:차오장, 날짜: 2023-11-06 11:43:14
태그:

img

전반적인 설명

이 전략은 가격 변동의 폭을 판단하기 위해 볼링거 밴드 지표를 이용하고, 가격 돌파운동을 위한 K-라인 패턴과 결합한다. 볼링거 밴드의 상부와 하부 레일은 가격의 상향 및 하향 트렌드를 대략적으로 판단할 수 있다. K-라인 패턴 지표와 결합하면 비교적 명백한 구매 및 판매 시기를 알아낼 수 있다. 이 전략은 주로 볼링거 밴드 아래의 돌파구를 길게, 레일 위의 돌파구를 짧게 판단하며, 오버구입 및 오버판매 상태를 판단하기 위해 스톡 지표를 결합하고, K-라인 패턴을 사용하여 대체 구매 및 판매 신호를 제공한다.

전략 원칙

이 전략은 다음과 같은 주요 지표로 구성됩니다.

  1. 볼링거 밴드 지표, 볼링거 중간 레일, 상부 레일 및 하부 레일을 포함합니다. 볼링거 밴드는 가격의 표준편차를 통해 가격 변동 범위를 계산하여 가격 변동 추세를 판단합니다.

  2. 주식 지표, 주식이 과소매 또는 과소매 상태에 있는지 판단하기 위해. K 라인과 D 라인은 파기 및 파기 여부를 판단 할 수 있습니다.

  3. K선 패턴, 대안적인 거래 기회로 큰 양선, 큰 선 등과 같은 일반적인 패턴을 판단합니다.

구매 조건: 가격은 볼링거 하부 레일을 넘고, 스톡 지표는 과잉 판매 상태를 보여줍니다 (K<20, D<20), 빠른 이동 평균은 느린 이동 평균을 넘습니다.

판매 조건: 가격이 볼링거 상부 레일 아래로 넘어가거나 수익성이있을 때 손실을 멈추게됩니다.

이 전략은 트렌드 분석과 과잉 구매 / 과잉 판매 판단을 결합하여 잘못된 신호의 비율을 줄이고 트렌드가 나타나면 적시에 시장 진출을 허용합니다. 그러나 함락 될 위험이 있으며 적시에 손실을 중단해야합니다.

이점 분석

  1. 볼링거 밴드와 스톡 지표를 결합하면 명백한 낮은 지점에서 구매할 수 있고 위험을 줄일 수 있습니다.

  2. K-라인 패턴은 보조 조건으로 사용되며, 범위에 묶인 시장에서 잘못된 구매를 피합니다.

  3. 이중 조건 판단의 채택은 전략의 안정성과 신뢰성을 향상시킵니다.

  4. 스톱 로스 메커니즘은 엄청난 손실을 피합니다.

위험 분석

  1. 볼링거 밴드 (Bollinger Bands) 를 이용한 거래는 함정에 빠질 가능성이 높습니다. 가격 불연속성은 상대적으로 큰 손실을 초래할 수 있습니다.

  2. 스톡 지표는 잘못된 신호를 발산 할 가능성이 높습니다. 스톡을 혼자 사용하는 것은 큰 손실 위험을 초래합니다.

  3. 범위를 제한하는 시장에서 잘못된 거래 신호를 생성하는 것이 쉽습니다.

  4. 위험을 통제하기 위해 적시에 손해를 멈추어야 합니다.

  5. 돌파구의 강도에 주의를 기울여야 합니다.

최적화 방향

  1. 주식 풀을 최적화하고 큰 변동과 명백한 추세를 가진 주식을 선택하십시오.

  2. 볼링거 매개 변수를 최적화하고, 중간 레일 사이클을 조정하고, 구매/판매 지점을 최적화합니다.

  3. 스톡 매개 변수를 최적화하고, K선과 D선 주기를 조정하고, 지표 신뢰성을 향상시킵니다.

  4. 거래량 조건 판단을 추가하면 높은 상승 후 인기를 회피할 수 있습니다.

  5. 손실 위험을 제어하기 위해 후속 스톱 손실, 이동 스톱 손실 등과 같은 스톱 손실 전략을 추가하십시오.

  6. 전략 안정성을 높이기 위해 MACD, KDJ 등과 같은 다른 기술 지표를 추가하는 것을 평가하십시오.

  7. 이윤과 사용 비율을 최적화하기 위해 다른 보유 기간을 테스트합니다.

요약

이 전략은 볼링거 밴드, 스톡 지표와 기술적 기본 지표를 통합한다. 위험을 통제한다는 전제 아래, 상대적으로 안정적인 수익 모델을 실현하여 가격 최저에서 구매하고 역사적인 최고에 가까운 판매를 한다. 그러나 함락, 비효율적인 스톱 로스 등과 같은 위험도 가지고 있다. 매개 변수 최적화와 다른 판단 지표를 추가함으로써 안정성과 수익성을 더욱 향상시킬 수 있다. 이 전략은 가격이 과소매와 과소매 부위에 변동할 때 거래하는 투자자에게 적합하다.


/*backtest
start: 2023-10-29 00:00:00
end: 2023-11-03 18:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Bollinger e Tendência", overlay=true)

//MÉDIAS 
periodolenta = 14
periodosimples = 47
periodome = 7

psimples = input(title="Período da média simples", defval=periodosimples)
pexp = input(title="Período da média exponencial", defval=periodome)
pexplenta = input(title="Período da média exp lenta", defval=periodolenta)
msimples = sma(close, psimples)
mexp = ema(close, pexp)
mexplenta = ema(close, pexplenta)

plot(msimples, linewidth=2, color=yellow)
plot(mexp, linewidth=5, color=white)
plot(mexplenta, linewidth=2, color=orange)

//BOLLANGER
length = input(21, minval=2)
src = input(close, title="Source")
mult = input(1.5, minval=0.001, maxval=50)
basis = sma(src, length)
dev = mult * stdev(src, length)
upperBol = basis + dev
lowerBol = basis - dev

p1 = plot(upperBol, title="Upper", color=blue, linewidth=3)
p2 = plot(lowerBol, title="Lower", color=blue, linewidth=3)
fill(p1, p2, color = purple, transp=90)

//BBW (altura do Bollanger)
basis2 = sma(close, 21)
bbw = (upperBol-lowerBol)/basis2


//STOCH E FORÇA
source = close
lengthRSI = input(11, minval=2), lengthStoch = input(7, minval=2)
smoothK = input(3,minval=3), smoothD = input(4,minval=3)
OverSold = input(20), OverBought = input(80)
rsi1 = rsi(source, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
hline(OverSold,color=blue)
hline(OverBought,color=blue)



// Cor das Tendências (Verde ou Vermelho)
// Baseado no código: "Pivot Daily Price Color" (by Rimko)
pivot = (high + low + close ) / 3.0 
dtime_pivot = request.security(syminfo.tickerid, 'D', pivot[1]) 
pv = dtime_pivot ? dtime_pivot : na
pe = ema(close,periodome)
col = sma(close,1)>pv?green:red
col2 = sma(close,1)>pe?green:red
offs_daily = 0 
pp=plot(pv, title="Daily Pivot",style=linebr, color=black,linewidth=2) 
p=plot(sma(close,1), transp=100, editable=false)
pema = plot(pe, title="EMA",style=line, color=black,linewidth=2, transp = 50)
fill(p,pema,color=col2,title="EMA to price color", transp = 50)
fill(pp,p,color=col, title="Privot to price color", transp = 90) 


//*************************************************************************************************************************************************
// Candles (identificação):
// Baseado no código: "Candlesticks Pattern Identified" (by Repo32)
trend= input(5, minval=1, title="Trend in Bars")

DojiSize = input(0.05, minval=0.01, title="Doji size")
data=(abs(open - close) <= (high - low) * DojiSize)
//plotchar(data, title="Doji", color=white)
plotshape(data, title="Doji", color=white, style=shape.cross)
 //text='Doji'

data6=(close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] and open[trend] < open)
plotshape(data6, title= "Bearish Harami", color=red, style=shape.triangledown)
//, text="Harami\nde Baixa"

data8=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] and open[trend] < open)
plotshape(data8,  title= "Bearish Engulfing", color=red, style=shape.triangledown)
//, text="Engolfo\nde Baixa"

data13=(open[1]<close[1] and open<=open[1] and close<=open and open[trend] < open)
plotshape(data13, title= "Bearish Kicker", color=red, style=shape.triangledown)
//, text="Kicker\nde Baixa"

data14=(((high-low>4*(open-close))and((close-low)/(.001+high-low)>=0.75)and((open-low)/(.001+high-low)>=0.75))and open[trend] < open and high[1] < open and high[2] < open)
plotshape(data14,  title= "Hanging Man", location=location.belowbar, color=red, style=shape.triangledown)
//, text="Enforcado"

data7=(open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] and open[trend] > open)
plotshape(data7,  title= "Bullish Harami", location=location.belowbar, color=lime, style=shape.triangleup)
//, text="Mulher\nGrávida"

data9=(open[1] > close[1] and close > open and close >= open[1] and close[1] >= open and close - open > open[1] - close[1] and open[trend] > open)
plotshape(data9, title= "Bullish Engulfing", location=location.belowbar, color=lime, style=shape.triangleup)
//, text="Engolfo\nde Alta"

//uppercandle = highest(10)[1]
data10=(close[1] < open[1] and  open < low[1] and close > close[1] + ((open[1] - close[1])/2) and close < open[1] and open[trend] > open)
plotshape(data10, title= "Piercing Line", location=location.belowbar, color=lime, style=shape.triangleup)
//, text="Piercing"

lowercandle = lowest(10)[1]
data11=(low == open and  open < lowercandle and open < close and close > ((high[1] - low[1]) / 2) + low[1] and open[trend] > open)
plotshape(data11, title= "Bullish Belt", location=location.belowbar, color=lime, style=shape.triangleup)
//, text="Contenção\nde Alta"

data12=(open[1]>close[1] and open>=open[1] and close>open and open[trend] > open)
plotshape(data12, title= "Bullish Kicker", location=location.belowbar, color=lime, style=shape.triangleup)//, text="Kicker\nde Alta"


data5=(((high - low)>3*(open -close)) and  ((close - low)/(.001 + high - low) > 0.6) and ((open - low)/(.001 + high - low) > 0.6))
plotshape(data5, title= "Hammer", location=location.belowbar, color=white, style=shape.diamond)

data5b=(((high - low)>3*(open -close)) and  ((high - close)/(.001 + high - low) > 0.6) and ((high - open)/(.001 + high - low) > 0.6))
plotshape(data5b, title= "Inverted Hammer", location=location.belowbar, color=white, style=shape.diamond)
//, text="Martelo\nInvertido"

data2=(close[2] > open[2] and min(open[1], close[1]) > close[2] and open < min(open[1], close[1]) and close < open )
//plotshape(data2, title= "Evening Star", location=location.belowbar, color=red, style=shape.arrowdown, text="Estrela\nda Tarde")
plotchar(data2, title="Evening Star", color=white)

data3=(close[2] < open[2] and max(open[1], close[1]) < close[2] and open > max(open[1], close[1]) and close > open )
//plotshape(data3,  title= "Morning Star", location=location.belowbar, color=lime, style=shape.arrowup, text="Estrela\nda Manhã")
plotchar(data3, title="Morning Star", color=white, location=location.belowbar)

data4=(open[1] < close[1] and open > close[1] and high - max(open, close) >= abs(open - close) * 3 and min(close, open) - low <= abs(open - close))
//plotshape(data4, title= "Shooting Star", color=red, style=shape.arrowdown, text="Estrela\nCadente")
plotchar(data4, title="Shooting Star", color=white)



//**********************************************************************************************************



// Ações:

momento = strategy.position_size[0] > strategy.position_size[1]
valorcompra = valuewhen(momento, open, 0)
valorbbw = input(title="Altura Máxima do Bollinger", defval=10)

alerta = crossunder(close, lowerBol)
alertcondition(alerta, title='Abaixo da Banda Baixa', message='Fechou abaixo da banda baixa...!')

//data7 data9 data10 data11 data12

compra =  crossover(close, lowerBol) and ((k<=20) and (d<=20)) and (mexp>mexp[1])
//compra = (data7 or data9 or data10 or data11 or data12) and (msimples>msimples[1]) and ((k<=20) and (d<=20)) and (bbw<valorbbw/1000)
//compra =  (open<close) and (crossover (close, lowerBol)) and ((k<=20) and (d<=20)) and (bbw<valorbbw/1000) and (msimples>msimples[1])

venda = crossover(close, upperBol)
//(close >= (valorcompra + (valorcompra * 0.025))) 

strategy.entry ("Compra", strategy.long, when=compra)
strategy.entry ("Venda", strategy.short, when=venda)


//plotshape(series=compra, title="Compra", style=shape.triangleup, location=location.belowbar, color=green, text="COMPRA", size=size.small)
//plotshape(series=venda, title="Venda", style=shape.triangledown, location=location.abovebar, color=red, text="VENDA", size=size.small)  






더 많은