
Chiến lược RSI-Bulling Band là một chiến lược giao dịch tích hợp các khái niệm của Bulling Band (BB), chỉ số tương đối mạnh (RSI) và đường trung bình di chuyển đơn giản (SMA). Điều độc đáo của chiến lược này là nó tính toán một mức độ động giữa đường lên và đường xuống dựa trên giá đóng cửa. Tính năng độc đáo này cho phép chiến lược thích ứng với biến động của thị trường và biến động giá cả.
Thị trường tiền điện tử và thị trường chứng khoán có sự biến động cao, nên rất thích hợp để áp dụng chiến lược Bollinger Bands. RSI có thể giúp xác định tình trạng quá mua quá bán trong thị trường thường xuyên đầu cơ này.
BollingBand động: Chiến lược này đầu tiên tính toán các BollingBand trên và dưới theo chiều dài và nhân số được định nghĩa bởi người dùng. Sau đó, kết hợp các BollingBand và giá đóng cửa động để điều chỉnh giá trị của BollingBand hiện tại. Cuối cùng, khi giá vượt qua BollingBand hiện tại, nó tạo ra tín hiệu nhiều và khi giá vượt qua BollingBand hiện tại, nó tạo ra tín hiệu trống.
RSI: Nếu người dùng chọn sử dụng RSI để tạo tín hiệu, chiến lược này cũng sẽ tính toán RSI và SMA của nó và sử dụng chúng để tạo ra các tín hiệu mua và bán bổ sung. Chỉ sử dụng tín hiệu dựa trên RSI khi bạn đặt tùy chọn chọn tạo tín hiệu bằng RSI thành true.
Sau đó, chiến lược kiểm tra hướng giao dịch đã chọn và tham gia vào các vị trí mua hoặc bán. Nếu hướng giao dịch được thiết lập là hai chiều, chiến lược có thể tham gia vào cả hai vị trí mua và bán.
Cuối cùng, khi giá đóng cửa vượt qua BollingBand hiện tại, nó sẽ bị phá vỡ.
Chiến lược này kết hợp các lợi thế của các chỉ số Brin, RSI và SMA, có thể thích ứng với sự biến động của thị trường, động lực nắm bắt biến động, tạo ra tín hiệu giao dịch trong trường hợp quá mua quá bán.
Chỉ số RSI bổ sung cho tín hiệu giao dịch Binance, tránh nhầm vào trong thị trường biến động. Cho phép lựa chọn chỉ giao dịch nhiều, chỉ giao dịch ngắn hoặc giao dịch hai chiều, thích ứng với các điều kiện thị trường khác nhau.
Các tham số có thể được tùy chỉnh để phù hợp với sở thích rủi ro cá nhân.
Chiến lược này phụ thuộc vào các chỉ số kỹ thuật và không thể đối phó với những thay đổi lớn về cơ bản.
Thiết lập tham số Brinh Băng không đúng có thể dẫn đến tín hiệu giao dịch quá thường xuyên hoặc quá thưa thớt.
Mức độ rủi ro giao dịch hai chiều tăng lên, cần cảnh giác với việc giảm giá.
Cố gắng kiểm soát rủi ro bằng cách kết hợp các lệnh dừng lỗ.
Kết hợp với các chỉ số khác để lọc tín hiệu, chẳng hạn như MACD.
Thêm chiến lược dừng lỗ.
Tối ưu hóa các tham số của BRI và RSI.
Điều chỉnh tham số theo các loại giao dịch và chu kỳ khác nhau.
Cân nhắc tối ưu hóa ổ cứng, điều chỉnh các tham số để phù hợp với tình hình thực tế.
Chiến lược này có thể tùy chỉnh và tối ưu hóa không gian lớn, nhưng không thể dự đoán được sự thay đổi cơ bản. Nó được đề xuất để kiểm tra hiệu quả thực tế, điều chỉnh tham số nếu cần thiết hoặc thêm các chỉ số khác để giảm rủi ro.
/*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.