OPEN-SOURCE SCRIPT
Telah dikemas kini

02 SMC + BB Breakout (Improved)

1 858
This strategy combines Smart Money Concepts (SMC) with Bollinger Band breakouts to identify potential trading opportunities. SMC focuses on identifying key price levels and market structure shifts, while Bollinger Bands help pinpoint overbought/oversold conditions and potential breakout points. The strategy also incorporates higher timeframe trend confirmation to filter out trades that go against the prevailing trend.

Key Components:

Bollinger Bands:

Calculated using a Simple Moving Average (SMA) of the closing price and a standard deviation multiplier.
The strategy uses the upper and lower bands to identify potential breakout points.
The SMA (basis) acts as a centerline and potential support/resistance level.
The fill between the upper and lower bands can be toggled by the user.
Higher Timeframe Trend Confirmation:

The strategy allows for optional confirmation of the current trend using a higher timeframe (e.g., daily).
It calculates the SMA of the higher timeframe's closing prices.
A bullish trend is confirmed if the higher timeframe's closing price is above its SMA.
This helps filter out trades that go against the prevailing long-term trend.
Smart Money Concepts (SMC):

Order Blocks:
Simplified as recent price clusters, identified by the highest high and lowest low over a specified lookback period.
These levels are considered potential areas of support or resistance.
Liquidity Zones (Swing Highs/Lows):
Identified by recent swing highs and lows, indicating areas where liquidity may be present.
The Swing highs and lows are calculated based on user defined lookback periods.
Market Structure Shift (MSS):
Identifies potential changes in market structure.
A bullish MSS occurs when the closing price breaks above a previous swing high.
A bearish MSS occurs when the closing price breaks below a previous swing low.
The swing high and low values used for the MSS are calculated based on the user defined swing length.
Entry Conditions:

Long Entry:
The closing price crosses above the upper Bollinger Band.
If higher timeframe confirmation is enabled, the higher timeframe trend must be bullish.
A bullish MSS must have occurred.
Short Entry:
The closing price crosses below the lower Bollinger Band.
If higher timeframe confirmation is enabled, the higher timeframe trend must be bearish.
A bearish MSS must have occurred.
Exit Conditions:

Long Exit:
The closing price crosses below the Bollinger Band basis.
Or the Closing price falls below 99% of the order block low.
Short Exit:
The closing price crosses above the Bollinger Band basis.
Or the closing price rises above 101% of the order block high.
Position Sizing:

The strategy calculates the position size based on a fixed percentage (5%) of the strategy's equity.
This helps manage risk by limiting the potential loss per trade.
Visualizations:

Bollinger Bands (upper, lower, and basis) are plotted on the chart.
SMC elements (order blocks, swing highs/lows) are plotted as lines, with user-adjustable visibility.
Entry and exit signals are plotted as shapes on the chart.
The Bollinger band fill opacity is adjustable by the user.
Trading Logic:

The strategy aims to capitalize on Bollinger Band breakouts that are confirmed by SMC signals and higher timeframe trend. It looks for breakouts that align with potential market structure shifts and key price levels (order blocks, swing highs/lows). The higher timeframe filter helps avoid trades that go against the overall trend.

In essence, the strategy attempts to identify high-probability breakout trades by combining momentum (Bollinger Bands) with structural analysis (SMC) and trend confirmation.

Key User-Adjustable Parameters:

Bollinger Bands Length
Standard Deviation Multiplier
Higher Timeframe
Higher Timeframe Confirmation (on/off)
SMC Elements Visibility (on/off)
Order block lookback length.
Swing lookback length.
Bollinger band fill opacity.
This detailed description should provide a comprehensive understanding of the strategy's logic and components.



***DISCLAIMER: This strategy is for educational purposes only. It is not financial advice. Past performance is not indicative of future results. Use at your own risk. Always perform thorough backtesting and forward testing before using any strategy in live trading.***
Nota Keluaran
Removed some elements from the code for cleaner chart.
Nota Keluaran
Users now have the option to filter trades based on the momentum of the breakout candle, requiring it to have a strong body relative to its overall size, enhancing entry signal confirmation.
Nota Keluaran
The script update adds visual highlighting for momentum candles. Candles where the body makes up a large percentage (default 70%) of the total range are now colored neon green if bullish (close > open) or neon red if bearish (close < open), making them easily identifiable on the chart.
Nota Keluaran
🔄 Summary of Changes Made:
1. ❌ Removed Higher Timeframe (HTF) Confirmation:

HTF logic was removed due to TradingView's alert system showing a "repaint" warning when using request.security().

While the strategy has always been non-repainting, this change avoids confusing warnings during alert setup and ensures a smoother user experience.

2. ✅ Strategy Remains 100% Non-Repainting:

All signals are based on closed candles from the current timeframe.

This ensures reliable backtests, consistent forward signals, and clean real-time alerts.

3. 📈 Added Adjustable Risk % Input:

Replaced the hardcoded 5% risk model with a user-configurable risk_percent_input (default: 15%).

This allows flexible position sizing based on personal risk appetite and account equity.

4. 📢 Custom Alerts Integrated:

Added alert_message strings for all key actions (entries and exits, long/short).

Optimized for webhook integration, bot automation, or mobile trading alerts.

5. 🧠 Refined Script Structure & Title:

Updated script title to:
"02 SMC + BB Breakout v4 + Momentum Color + Alerts (No HTF, Adj Risk)"

Improved code readability and modularity with cleaner logic and clearer comments.
Nota Keluaran
🔄 Summary of Key Updates in the Strategy Code:

Initial Capital Adjusted:
The starting capital in the strategy() declaration has been changed from the default (usually $100,000) to initial_capital=10000, simulating trading with a more realistic small account.

Commission and Slippage Added:
Realistic trading conditions are now applied using commission_type=strategy.commission.percent, commission_value=0.1, and slippage=2. This models a 0.1% trading fee and minor price execution delays.

Risk Management Toned Down:
The default risk per trade was reduced from 15% to a safer 5%, promoting better capital preservation.

Unchanged Core Logic:
All the core components—Bollinger Band breakouts, SMC logic, momentum filters, entry/exit rules, and plotting—remain intact and functional.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.