Bollinger Bands Oscillator | QuantMAC

🎯 Overview
The Bollinger Bands Oscillator is a sophisticated technical analysis tool that combines the power of traditional Bollinger Bands with an oscillator-based approach for enhanced signal generation. This indicator transforms the classic Bollinger Bands into a percentage-based oscillator, providing clearer entry and exit signals for both trending and ranging markets.
🔧 Key Features
- Dual Trading Modes: Choose between Long/Short or Long/Cash strategies
- Advanced BB% Calculation: Enhanced Bollinger Band percentage with customizable multipliers
- Comprehensive Metrics: Built-in performance analytics including Sharpe Ratio, Sortino Ratio, and Profit Factor
- Visual Color Coding: Dynamic bar coloring and 9 different color schemes for optimal chart visibility
- Date Range Filtering: Backtest specific time periods with customizable start dates
- Real-time Signal Generation: Clear long and short entry signals with threshold customization
- Advanced Risk Management: Half Kelly criterion calculation for optimal position sizing
📈 How It Works
The indicator operates by calculating a modified Bollinger Band percentage that oscillates between values, typically ranging from 0 to 100+. When the BB% crosses above the Long Threshold (default: 83), it generates a bullish signal. Conversely, when it crosses below the Short Threshold (default: 55), it produces a bearish signal.
Core Calculation Process:
- Calculate the moving average basis using the specified Base Length (default: 40 periods)
- Determine standard deviation using a separate SD Length (default: 27 periods)
- Create upper and lower bands using the SD Multiplier (default: 2.6)
- Convert to percentage oscillator with BB% Multiplier (default: 100)
- Generate signals based on threshold crossovers
⚙️ Customizable Parameters
BMD Settings:
- Base Length: Controls the moving average period (default: 40)
- Standard Deviation Length: Determines volatility calculation period (default: 27)
- SD Multiplier: Adjusts band width sensitivity (default: 2.6)
- BB% Multiplier: Scales the oscillator values (default: 100)
- Source: Choose price source (close, open, high, low, etc.)
Signal Thresholds:
- Long Threshold: Entry level for bullish positions (default: 83)
- Short Threshold: Entry level for bearish positions (default: 55)
🎨 Visual Elements
Main Chart Overlay:
- Bollinger Bands: Upper and lower bands with customizable colors and transparency
- Middle Line: Basis line displayed as subtle dots
- Band Fill: Colored area between bands for easy visualization
- Bar Coloring: Candles change color based on current signal state
Separate Oscillator Pane:
- BB% Line: Main oscillator line with dynamic coloring
- Threshold Lines: Horizontal lines marking entry/exit levels
- Color Coding: Line colors change based on bullish/bearish state
📊 Performance Metrics
The indicator includes a comprehensive metrics table displaying:
- Net Profit %: Total return percentage
- Max Drawdown %: Maximum peak-to-trough decline
- Win Rate %: Percentage of profitable trades
- Profit Factor: Ratio of gross profit to gross loss
- Sharpe Ratio: Risk-adjusted return measure
- Sortino Ratio: Downside risk-adjusted return
- Omega Ratio: Probability-weighted ratio of gains vs losses
- Half Kelly %: Optimal position sizing recommendation
- Total Trades: Number of completed transactions
🎯 Trading Strategies
Long/Short Mode: 🔄
The indicator alternates between long and short positions based on threshold crossovers. This mode is ideal for traders who can profit from both rising and falling markets.
Long/Cash Mode: 💰
This conservative approach only takes long positions, moving to cash during bearish signals. Perfect for traders in accounts that don't allow short selling or those preferring a buy-and-hold approach with strategic exits.
🚀 Getting Started
- Add the indicator to your chart
- Choose your preferred Trading Mode (Long/Short or Long/Cash)
- Adjust the Base Length and SD Length to match your trading timeframe
- Fine-tune the Long Threshold and Short Threshold based on your risk tolerance
- Select your preferred color scheme from 9 available options
- Enable the metrics table to monitor performance in real-time
💡 Pro Tips
- Lower thresholds (e.g., Long: 75, Short: 60) generate more frequent but potentially less reliable signals
- Higher thresholds (e.g., Long: 90, Short: 45) produce fewer but potentially higher-quality signals
- Shorter base lengths make the indicator more responsive to recent price action
- Longer base lengths smooth out noise but may lag market turns
- Use the Half Kelly % metric to guide position sizing decisions
⚠️ Important Disclaimers
Past performance is not indicative of future results. This indicator is a technical analysis tool designed to assist in trading decisions but should not be used as the sole basis for investment choices.
Key Risk Considerations:
- Market Conditions: No indicator works perfectly in all market environments
- Backtesting Bias: Historical performance may not reflect future market behavior
- Risk Management: Always use proper position sizing and stop-loss orders
- Multiple Confirmations: Consider using additional indicators and analysis methods
📚 Educational Value
This indicator serves as an excellent learning tool for understanding:
- Bollinger Band mechanics and interpretation
- Oscillator-based trading strategies
- Performance metrics and risk assessment
- Position sizing using Kelly Criterion principles
- The relationship between volatility and price movement
🔔 Updates and Support
The Bollinger Bands Oscillator | QuantMAC is regularly updated to ensure compatibility with TradingView's latest features. The code is thoroughly commented for educational purposes and transparency.
Remember: Trading involves substantial risk of loss and is not suitable for all investors. The value of investments may go down as well as up, and you may not get back the amount you invested. Always conduct your own research and consider seeking advice from a qualified financial advisor.
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi Quant_MAC secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi Quant_MAC secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.