
Chiến lược này là một hệ thống giao dịch định lượng cao cấp dựa trên Bollinger Bands, kết hợp với cơ chế dừng lỗ động. Cốt lõi của chiến lược là nắm bắt động lực thị trường bằng cách phá vỡ Bollinger Bands xuống đường, đồng thời giới thiệu dừng lỗ dựa trên số điểm (Pips) để quản lý rủi ro. Chiến lược này phù hợp với nhiều loại giao dịch khác nhau, có thể thích ứng với môi trường thị trường khác nhau thông qua tối ưu hóa tham số.
Chiến lược này dựa trên những nguyên tắc cốt lõi sau:
Đây là một chiến lược giao dịch định lượng được thiết kế tốt, nắm bắt cơ hội thị trường thông qua đột phá trong vòng Brin, và được hỗ trợ bởi hệ thống quản lý rủi ro khoa học. Chiến lược có khả năng mở rộng và thích ứng tốt, có thể nâng cao hiệu suất của nó hơn nữa thông qua hướng tối ưu hóa được đề xuất.
/*backtest
start: 2022-02-09 00:00:00
end: 2025-02-06 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced Bollinger Bands Strategy with SL/TP", overlay=true,
slippage=2)
// 入力パラメータの改善
length = input.int(20, "SMA Length", minval=1)
mult = input.float(2.0, "Standard Deviation Multiplier", minval=0.001, maxval=50)
enableLong = input.bool(true, "Enable Long Positions")
enableShort = input.bool(true, "Enable Short Positions")
pipValue = input.float(0.0001, "Pip Value", step=0.00001)
slPips = input.float(10, "Stop Loss (Pips)", minval=0)
tpPips = input.float(20, "Take Profit (Pips)", minval=0)
showBands = input.bool(true, "Show Bollinger Bands")
showSignals = input.bool(true, "Show Entry Signals")
// ボリンジャーバンド計算
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// 可視化
plot(showBands ? basis : na, "Basis", color=color.blue)
u = plot(showBands ? upper : na, "Upper", color=color.red)
l = plot(showBands ? lower : na, "Lower", color=color.green)
fill(u, l, color=color.new(color.purple, 90))
// エントリー条件の改善
longCondition = ta.crossover(close, lower) and close > lower and enableLong
shortCondition = ta.crossunder(close, upper) and close < upper and enableShort
// ポジション管理
calcSlPrice(price, isLong) => isLong ? price - slPips * pipValue : price + slPips * pipValue
calcTpPrice(price, isLong) => isLong ? price + tpPips * pipValue : price - tpPips * pipValue
// エントリー&エグジットロジック
if longCondition
strategy.entry("Long", strategy.long, limit=lower)
strategy.exit("Long Exit", "Long",
stop=calcSlPrice(lower, true),
limit=calcTpPrice(lower, true))
if shortCondition
strategy.entry("Short", strategy.short, limit=upper)
strategy.exit("Short Exit", "Short",
stop=calcSlPrice(upper, false),
limit=calcTpPrice(upper, false))
// シグナル可視化
plotshape(showSignals and longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(showSignals and shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)