
この戦略は,ブリン帯,相対的に強い指数 ((RSI) と商品経路指数 ((CCI) の3つの指標を組み合わせて,その交差信号を探し,買入と売却のシグナルを発出する. この戦略は,市場の超買い超売り現象を発見し,逆転点で市場に入場し,より良い投資リターンを得ることを期待する.
ブリン帯は,中軌道,上軌道,下軌道で構成されている。中軌道には通常20日移動平均が用いられている。上軌道と下軌道は,それぞれ中軌道上下2つの標準差の位置である。価格が下軌道に近づくと,超売り信号とみなされる。価格が上軌道に近づくと,超買い信号とみなされる。
RSI指標は,期間内に収束価格の上昇と下落の速度の変化を反映し,買い値と売り値の力の対比を測定するために使用されます. RSI値は0から30時には超売区,70から100時には超買区です. RSIが超買区から下落すると,売り信号として使用できます.
CCI指標は,株価が平均価格から偏っている程度を測定するために使用される. +100は,平均価格よりはるかに高い価格を表し,超買いである;-100は,平均価格よりはるかに低い価格を表し,超売りである.CCIは,価格を反映できる極端な状況である.
この策略は,ブリン帯で価格が短期間に超買超売かどうかを判断し,RSI指標で買取市場力の均衡状況を判断し,CCI指標で価格偏差の程度を判断する. ブリン帯,RSIおよびCCI指標が同時に買取/売り信号を与える時,取引指示を発行する.
この戦略は,短期,中期,長期の市場状況を総合的に考慮し,ブリン帯,RSI,CCIの3つの指標の交差信号を使用して,市場の逆転のタイミングを判断し,より堅牢な逆転追跡戦略に属します.パラメータ調整,ストップ方式などによりさらに最適化され,複数の市場環境に適用されます.
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(shorttitle="BBRSIstr", title="Bollinger Bands", overlay=true)
length = input.int(20, minval=1)
maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
//RSI
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(14, title="MA Length", group="MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")
showDivergence = input.bool(false, title="Show Divergence", group="RSI Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
plot(rsiMA, "RSI-based MA", color=color.yellow)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
//cci
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(cci, "CCI", color=#2962FF)
band1 = hline(100, "Upper Band", color=#787B86, linestyle=hline.style_dashed)
hline(0, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(-100, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.rgb(33, 150, 243, 90), title="Background")
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")
smoothingLine = ma(cci, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, display=display.none)
longCBB= close < lower
shortCBB = close>upper
longBRSI = rsi < 33
shortBRSI = rsi > 70
longcci = cci < -215
shortcci = cci > 250
strategy.entry("LONG", strategy.long, when = longCBB and longBRSI and longcci)
strategy.exit("Exit ", profit = 600)
strategy.entry("SHORT", strategy.short, when = shortCBB and shortBRSI and shortcci)
strategy.exit("Exit ", profit = 600)