波動性を把握するRSI・ボリンジャーバンド戦略

作者: リン・ハーンチャオチャン開催日:2023年12月1日 (火) 14:17:55
タグ:

img

概要

波動性キャプチャー RSI-ボリンジャーバンド戦略は,ボリンジャーバンド (BB),相対強度指数 (RSI),シンプル・ムービング・平均 (SMA) のコンセプトを統合した取引戦略である.この戦略のユニークさは,閉値に基づいて上下ボリンジャーバンド間の動的レベルを計算することである.このユニークな機能により,戦略は市場の波動性と価格動に適応することができる.

暗号通貨と株式市場は非常に不安定で,ボリンジャー帯を使用する戦略に適しています.RSIは,これらのしばしば投機的な市場で過買いまたは過売状態を特定するのに役立ちます.

働き方

ダイナミック・ボリンガーバンド: 戦略は,最初にユーザー定義の長さと倍数に基づいて上下ボリンガーバンドを計算する.その後,ボリンガーバンドと閉値を使用して,現在のボリンガーバンド値を動的に調整する.最後に,価格が現在のボリンガーバンドを越えたときに長い信号,価格が下を横断したときのショート信号を生成する.

RSI:ユーザがRSIをシグナルに使用することを選択した場合,戦略はRSIとそのSMAを計算し,それらを追加的なロングとショートシグナルを生成するために使用します.

戦略は,選択したトレード方向をチェックし,それに応じてロングまたはショートポジションを入力します. Both に設定された場合,ロングとショートポジションの両方を入力できます.

最後に,ストラテジーは,閉じる価格が現在のボリングバンドの下/上を横切ると,それぞれロング・ショート・ポジションを終了します.

利点分析

この戦略は,ボリンジャー・バンド,RSI,SMAの強みを組み合わせて,市場の変動に適応し,変動を動的に把握し,過買い/過売りレベルでの取引信号を生成します.

RSIは波リンジャー信号を補完し,波動市場での誤ったエントリーを回避する.ロングのみ,ショートのみ,または両方の方向を許可することで,異なる市場条件に対応する.

パーソナライズ可能なパラメータは,個々のリスク優先順位に基づいて調整することができます.

リスク分析

この戦略は技術指標に基づいているため,根本的な大きな逆転を予測することはできません.

不適切なボリンジャーパラメータ設定は,頻繁に信号を発信したり,少々信号を発信したりする可能性があります.

双方向取引はリスクを増大させる 逆のショート損失に気をつけろ

リスクを制御するためにストップを使用することが推奨されます.

オプティマイゼーションの方向性

  1. フィルター信号にMACDのような他のフィルターを追加します.

  2. ストップ・ロスの戦略を組み込む

  3. ボリンジャーとRSIのパラメータを最適化します

  4. 異なる製品と時間枠のパラメータを調整します

  5. リアル条件に合わせて リアルチューニングパラメータを考慮してください

概要

波動性キャプチャーRSI-ボリンジャー戦略は,ボリンジャーバンド,RSIおよびSMAの強みを組み合わせて,ボリンジャーバンドを動的に調整して市場の変動をキャプチャする技術指標駆動戦略である.この戦略は高いカスタマイズ性と最適化を可能にするが,根本的な変化を予測することはできません.実際の取引の検証とパラメータ調整または必要に応じてリスクを減らすために他の指標を追加することが推奨される.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

//@version=5
// Define the strategy settings
strategy('Volatility Capture RSI-Bollinger - Strategy [presentTrading]', overlay=true)

// Define the input parameters for the indicator
priceSource  = input.source(title='Source', defval=hlc3, group='presentBollingBand') // The price source to use
lengthParam   = input.int(50, 'lengthParam', minval=1, group='presentBollingBand') // The length of the moving average
multiplier = input.float(2.7183, 'Multiplier', minval=0.1, step=.1, group='presentBollingBand') // The multiplier for the ATR
useRSI = input.bool(true, 'Use RSI for signals', group='presentBollingBand') // Boolean input to decide whether to use RSI for signals
rsiPeriod = input.int(10, 'RSI Period', minval=1, group='presentBollingBand') // The period for the RSI calculation
smaPeriod = input.int(5, 'SMA Period', minval=1, group='presentBollingBand') // The period for the SMA calculation
boughtRange = input.float(55, 'Bought Range Level', minval=1, group='presentBollingBand') // The level for the bought range
soldRange = input.float(50, 'Sold Range Level', minval=1, group='presentBollingBand') // The level for the sold range

// Add a parameter for choosing Long or Short
tradeDirection = input.string("Both", "Trade Direction", options=["Long", "Short", "Both"], group='presentBollingBand') // Dropdown input for trade direction

// Calculate the bollingerBand
barIndex = bar_index // The current bar index
upperBollingerBand = ta.sma(high, lengthParam) + ta.stdev(high, lengthParam) * multiplier // Calculate the upper Bollinger Band
lowerBollingerBand = ta.sma(low, lengthParam) - ta.stdev(low, lengthParam) * multiplier // Calculate the lower Bollinger Band

var float presentBollingBand = na // Initialize the presentBollingBand variable
crossCount = 0 // Initialize the crossCount variable

// Calculate the buy and sell signals
longSignal1 = ta.crossover(priceSource, presentBollingBand) // Calculate the long signal
shortSignal1 = ta.crossunder(priceSource, presentBollingBand) // Calculate the short signal

// Calculate the RSI
rsiValue = ta.rsi(priceSource, rsiPeriod) // Calculate the RSI value
rsiSmaValue = ta.sma(rsiValue, smaPeriod) // Calculate the SMA of the RSI value

// Calculate the buy and sell signals
longSignal2 = rsiSmaValue > boughtRange // Calculate the long signal based on the RSI SMA
shortSignal2 = rsiSmaValue < soldRange // Calculate the short signal based on the RSI SMA

presentBollingBand := na(lowerBollingerBand) or na(upperBollingerBand)?0.0 : close>presentBollingBand?math.max(presentBollingBand,lowerBollingerBand) : close<presentBollingBand?math.min(presentBollingBand,upperBollingerBand) : 0.0


if (tradeDirection == "Long" or tradeDirection == "Both") and longSignal1 and (useRSI ? longSignal2 : true) // Use RSI for signals if useRSI is true
    presentBollingBand := lowerBollingerBand // If the trade direction is "Long" or "Both", and the long signal is true, and either useRSI is false or the long signal based on RSI is true, then assign the lowerBollingerBand to the presentBollingBand.
    strategy.entry("Long", strategy.long) // Enter a long position.

if (tradeDirection == "Short" or tradeDirection == "Both") and shortSignal1 and (useRSI ? shortSignal2 : true) // Use RSI for signals if useRSI is true
    presentBollingBand := upperBollingerBand // If the trade direction is "Short" or "Both", and the short signal is true, and either useRSI is false or the short signal based on RSI is true, then assign the upperBollingerBand to the presentBollingBand.
    strategy.entry("Short", strategy.short) // Enter a short position.

// Exit condition
if (strategy.position_size > 0 and ta.crossunder(close, presentBollingBand)) // If the strategy has a long position and the close price crosses under the presentBollingBand, then close the long position.
    strategy.close("Long")
if (strategy.position_size < 0 and ta.crossover(close, presentBollingBand)) // If the strategy has a short position and the close price crosses over the presentBollingBand, then close the short position.
    strategy.close("Short")

//~~ Plot
plot(presentBollingBand,"presentBollingBand", color=color.blue) // Plot the presentBollingBand on the chart.

もっと