価格突破 ボリンガーバンドA戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月6日 11:43:14
タグ:

img

概要

この戦略は,価格変動の幅を判断するためにボリンジャーバンド指標を使用し,価格突破操作のためのK線パターンと組み合わせます.ボリンジャーバンドの上下線は,価格の上下走勢を概して判断できます.K線パターン指標と組み合わせると,比較的明らかな購入・販売タイミングがわかります.この戦略は,主にボリンジャーバンドの下の突破を長引,レール上部の突破を短引と判断し,ストック指標を組み合わせて,過剰購入・過売り状態を判断し,代替的な購入・売却信号を提供するためにK線パターンを使用します.

戦略原則

戦略は以下の主要指標からなる.

  1. ボリンジャー・バンド指標は,ボリンジャー・ミドル・レール,上部レール,下部レールを含む.ボリンジャー・バンドは,価格の標準偏差によって価格の変動範囲を計算し,それによって価格の変動傾向を判断する.

  2. 株価指標で,株価が過買い・過売状態にあるかどうかを判断する.K線とD線は,分割・破損を判断できる.

  3. 大型ヤン線,大型イン線など, 代替取引機会として判断します.

購入条件:価格がボリンジャー・ローナー・レールの上を突破,ストック指標が過売状態を示し (K<20,D<20),高速移動平均がスロー移動平均を突破.

売り条件: 価格がボリンガー上線を下回り,利益が出るとストップ・ロスをします.

この戦略は,トレンド分析とオーバーバイト/オーバーセール判断の両方を組み合わせ,誤ったシグナルの割合を軽減し,トレンドが現れるときに適時に市場に参入することを可能にします.しかし,罠にかかったリスクも伴い,適時にストップ損失を必要とします.

利点分析

  1. ボリンジャー・バンドとストック・インディケーターを組み合わせると リスクを減らすために 明らかに低い値で購入できます

  2. K線パターンは補助条件として機能し,範囲限定市場での間違った購入を回避します.

  3. 双重条件判断を採択することで 戦略の安定性と信頼性が向上します

  4. ストップ・ロスのメカニズムは 大きな損失を回避します

リスク分析

  1. ボリンジャー帯で取引する場合は 罠にかかりやすい.価格の不連続性は比較的大きな損失を引き起こす可能性があります.

  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)  






もっと