
この戦略は、ボリンジャーバンド、ボラティリティ、リスク管理を組み合わせたトレンドフォローシステムです。主にボリンジャーバンドの上限と下限を価格が突破する方法を監視することでトレンドの機会を捉え、同時にATRと組み合わせてポジションサイズを動的に調整し、正確なリスク管理を実現します。この戦略には、市場の統合期間を特定し、不安定な市場で誤ったシグナルを効果的に排除するメカニズムも組み込まれています。
この戦略は、次のコアロジックに基づいて機能します。
この戦略は、ボリンジャー バンドのブレイクアウトを通じてトレンドを捉え、それを健全なリスク管理システムと組み合わせます。その利点は、適応性が強く、リスクを制御できることですが、誤ったブレイクスルーやトレンドの反転のリスクには依然として注意を払う必要があります。トレンド確認インジケーターの追加、パラメータ調整メカニズムの最適化などにより、戦略をさらに改善する余地がまだあります。全体として、これは明確なロジックと強力な実用性を備えたトレンド追従戦略です。
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands Breakout Strategy", overlay=true)
// Input parameters
length = input(20, title="Bollinger Bands Length")
stdDev = input(2.0, title="Standard Deviation")
riskRewardRatio = input(2.0, title="Risk/Reward Ratio")
atrLength = input(14, title="ATR Length")
riskPercentage = input(1.0, title="Risk Percentage per Trade")
// Calculate Bollinger Bands
basis = ta.sma(close, length)
dev = stdDev * ta.stdev(close, length)
upperBand = basis + dev
lowerBand = basis - dev
// Calculate ATR for position sizing
atr = ta.atr(atrLength)
// Plot Bollinger Bands
plot(basis, color=color.blue, title="Basis")
plot(upperBand, color=color.red, title="Upper Band")
plot(lowerBand, color=color.green, title="Lower Band")
// Market Consolidation Detection
isConsolidating = (upperBand - lowerBand) < ta.sma(upperBand - lowerBand, length) * 0.5
// Breakout Conditions
longCondition = ta.crossover(close, upperBand) and not isConsolidating
shortCondition = ta.crossunder(close, lowerBand) and not isConsolidating
// Risk Management: Calculate position size
equity = strategy.equity
riskAmount = equity * (riskPercentage / 100)
positionSize = riskAmount / (atr * riskRewardRatio)
// Execute trades with risk management
if (longCondition)
strategy.entry("Long", strategy.long, qty=positionSize)
strategy.exit("Take Profit", from_entry="Long", limit=close + atr * riskRewardRatio, stop=close - atr)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=positionSize)
strategy.exit("Take Profit", from_entry="Short", limit=close - atr * riskRewardRatio, stop=close + atr)
// Alert conditions for breakouts
alertcondition(longCondition, title="Long Breakout", message="Long breakout detected!")
alertcondition(shortCondition, title="Short Breakout", message="Short breakout detected!")