
Chiến lược này là một hệ thống giao dịch động dựa trên các chỉ số Bollinger Band, tạo ra tín hiệu giao dịch chủ yếu bằng cách giao giá với Bollinger Band và kết hợp các điểm cao và thấp chạm vào biên giới Bollinger Band như một điều kiện thoát ra động. Chiến lược này tận dụng tối đa đặc tính của Bollinger Band là khu vực biến động giá, tìm kiếm cơ hội giao dịch khi giá lệch khỏi trung bình, bảo vệ lợi nhuận và kiểm soát rủi ro bằng cơ chế thoát ra động.
Logic cốt lõi của chiến lược bao gồm các yếu tố chính sau:
Chiến lược này xây dựng một hệ thống giao dịch hoàn chỉnh thông qua các chỉ số Bollinger Bands, có logic giao dịch rõ ràng và cơ chế quản lý rủi ro. Mặc dù có một số rủi ro tiềm ẩn, nhưng có thể nâng cao hơn nữa hiệu suất của nó trong các môi trường thị trường khác nhau bằng cách tối ưu hóa tham số và cải tiến chiến lược thích hợp.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//
// #######################################
// # #
// # Taexion #
// # #
// #######################################
//
//@version=6
strategy("Bollinger Strategy: Close at Band Touch v6", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=1000)
// Bollinger Bands parameters
length = input.int(10, title="Bollinger Period")
mult = input.float(2.0, title="Multiplier", step=0.1)
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// Plotting the bands
plot(basis, color=color.blue, title="Base")
p1 = plot(upper, color=color.red, title="Upper Band")
p2 = plot(lower, color=color.green, title="Lower Band")
fill(p1, p2, color=color.new(color.blue, 90), title="Band Fill")
// Entry signals
longEntry = ta.crossover(close, lower)
shortEntry = ta.crossunder(close, upper)
if longEntry
strategy.entry("Long", strategy.long)
if shortEntry
strategy.entry("Short", strategy.short)
// Exit conditions based on touching the bands
// If in a long position and the candle's high touches or exceeds the upper band, close long.
if strategy.position_size > 0 and high >= upper
strategy.close("Long")
// If in a short position and the candle's low touches or falls below the lower band, close short.
if strategy.position_size < 0 and low <= lower
strategy.close("Short")