Strategi RSI-Bollinger Band untuk Mengekap Volatiliti

Penulis:ChaoZhang, Tarikh: 2023-12-01 14:17:55
Tag:

img

Ringkasan

Strategi Volatility Capture RSI-Bollinger Band adalah strategi perdagangan yang mengintegrasikan konsep Bollinger Bands (BB), Indeks Kekuatan Relatif (RSI) dan Purata Bergerak Sederhana (SMA) untuk menjana isyarat perdagangan. Keunikan strategi ini adalah bahawa ia mengira tahap dinamik antara Bollinger Bands atas dan bawah berdasarkan harga penutupan. Ciri unik ini membolehkan strategi untuk menyesuaikan diri dengan turun naik pasaran dan pergerakan harga.

Pasaran crypto dan saham sangat tidak menentu, menjadikannya sesuai untuk strategi menggunakan Bollinger Bands. RSI dapat membantu mengenal pasti keadaan overbought atau oversold di pasaran yang sering berspekulasi ini.

Cara Ia Bekerja

Bollinger Band Dinamik: Strategi ini mula-mula mengira Bollinger Band atas dan bawah berdasarkan panjang dan pengganda yang ditakrifkan oleh pengguna. Kemudian ia menggunakan Bollinger Band dan harga penutupan untuk menyesuaikan nilai BollingBand semasa secara dinamik. Akhirnya, ia menghasilkan isyarat panjang apabila harga melintasi Bolling Band semasa dan isyarat pendek apabila harga melintasi di bawah.

RSI: Jika pengguna memilih untuk menggunakan RSI untuk isyarat, strategi juga mengira RSI dan SMA, dan menggunakannya untuk menjana isyarat panjang dan pendek tambahan. Isyarat RSI hanya digunakan jika pilihan Gunakan RSI untuk isyarat diaktifkan.

Strategi kemudian memeriksa arah perdagangan yang dipilih dan memasuki kedudukan panjang atau pendek.

Akhirnya, strategi keluar dari kedudukan apabila harga penutupan melintasi di bawah / di atas Band Bolling semasa untuk kedudukan panjang / pendek masing-masing.

Analisis Kelebihan

Strategi ini menggabungkan kekuatan Bollinger Bands, RSI dan SMA untuk menyesuaikan diri dengan turun naik pasaran, menangkap turun naik secara dinamik dan menjana isyarat perdagangan pada tahap overbought / oversold.

RSI melengkapkan isyarat Bollinger, mengelakkan kemasukan palsu di pasaran julat.

Parameter yang boleh disesuaikan membolehkan penyesuaian berdasarkan pilihan risiko individu.

Analisis Risiko

Strategi ini bergantung kepada penunjuk teknikal dan tidak dapat menjangkakan pembalikan utama yang didorong oleh asas.

Tetapan parameter Bollinger yang tidak betul boleh menghasilkan isyarat yang terlalu kerap atau terlalu jarang.

Perdagangan dua hala meningkatkan risiko, berhati-hati dengan kerugian pendek.

Penggunaan hentian untuk mengawal risiko disyorkan.

Arahan pengoptimuman

  1. Tambah penapis lain seperti MACD untuk menapis isyarat.

  2. Menggabungkan strategi stop loss.

  3. Mengoptimumkan parameter Bollinger dan RSI.

  4. Sesuaikan parameter untuk produk dan jangka masa yang berbeza.

  5. Pertimbangkan parameter penyesuaian hidup untuk menyesuaikan keadaan sebenar.

Ringkasan

Strategi Volatility Capture RSI-Bollinger adalah strategi yang didorong oleh penunjuk teknikal, menggabungkan kekuatan Bollinger Bands, RSI dan SMA dengan menyesuaikan Bollinger Bands secara dinamik untuk menangkap turun naik pasaran. Strategi ini membolehkan penyesuaian dan pengoptimuman yang tinggi tetapi tidak dapat meramalkan perubahan asas.


/*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.

Lebih lanjut