OPEN-SOURCE SCRIPT
Enhanced BTC Order Block Indicator

The script you provided is an "Enhanced BTC Order Block Indicator" written in Pine Script v5 for TradingView. It is designed to identify and visually mark Order Blocks (OBs) on a Bitcoin (BTC) price chart, specifically tailored for a high-frequency scalping strategy on the 5-minute (M5) timeframe. Order Blocks are key price zones where institutional traders are likely to have placed significant buy or sell orders, making them high-probability areas for reversals or continuations. The script incorporates customizable filters, visual indicators, and alert functionality to assist traders in executing the strategy outlined earlier.
Key Features and Functionality
Purpose:
The indicator detects bullish Order Blocks (buy zones) and bearish Order Blocks (sell zones) based on a predefined percentage price movement (default 0.5–1%) and volume confirmation.
It marks these zones on the chart with colored boxes and provides alerts when an OB is detected.
User-Configurable Inputs:
Price Move Range: minMovePercent (default 0.5%) and maxMovePercent (default 1.0%) define the acceptable price movement range for identifying OBs.
Volume Threshold: volumeThreshold (default 1.5x average volume) ensures OB detection is backed by significant trading activity.
Lookback Period: lookback (default 10 candles) determines how many previous candles are analyzed to find the last candle before a strong move.
Wick/Body Option: useWick (default false) allows users to choose whether the OB zone is based on the candle’s wick or body.
Colors: bullishOBColor (default green) and bearishOBColor (default red) set the visual appearance of OB boxes.
Box Extension: boxExtension (default 100 bars) controls how far the OB box extends to the right on the chart.
RSI Filter: useRSI (default true) enables an RSI filter, with rsiLength (default 14), rsiBullishThreshold (default 50), and rsiBearishThreshold (default 50) for trend confirmation.
M15 Support/Resistance: useSR (default true) and srLookback (default 20) integrate M15 timeframe swing highs and lows for additional OB validation.
Core Logic:
Bullish OB Detection: Identifies a strong upward move (0.5–1%) with volume above the threshold. It then looks back to the last bearish candle before the move to define the OB zone. RSI > 50 and proximity to M15 support/resistance (optional) enhance confirmation.
Bearish OB Detection: Identifies a strong downward move (0.5–1%) with volume confirmation, tracing back to the last bullish candle. RSI < 50 and M15 resistance proximity (optional) add validation.
The OB zone is drawn as a rectangle from the high to low of the identified candle, extended rightward.
Visual Output:
Boxes: Uses box.new to draw OB zones, with left set to the previous bar (bar_index[1]), right extended by boxExtension, top and bottom defined by the OB’s high and low prices. Each box includes a text label ("Bullish OB" or "Bearish OB") and is semi-transparent.
Colors distinguish between bullish (green) and bearish (red) OBs.
Alerts:
Global alertcondition definitions trigger notifications for "Bullish OB Detected" and "Bearish OB Detected" when the respective conditions are met, displaying the current close price in the message.
Helper Functions:
f_priceChangePercent: Calculates the percentage price change between open and close prices.
isNearSR: Checks if the price is within 0.2% of M15 swing highs or lows for support/resistance confluence.
How It Works
The script runs on each candle, evaluating the current price action against the user-defined criteria.
When a bullish or bearish move is detected (meeting the percentage, volume, RSI, and S/R conditions), it identifies the preceding candle to define the OB zone.
The OB is then visualized on the chart, and an alert is triggered if configured in TradingView.
Use Case
This indicator is tailored for your BTC scalping strategy, where trades last 1–15 minutes targeting 0.3–0.5% gains. It helps traders spot institutional order zones on the M5 chart, confirmed by secondary M1 analysis, and integrates with your use of EMAs, RSI, and volume. The customizable settings allow adaptation to varying market conditions or personal preferences.
Limitations
The M15 S/R detection is simplified (using swing highs/lows), which may not always align perfectly with manual support/resistance levels.
Alerts depend on TradingView’s alert system and require manual setup.
Performance may vary with high volatility or low-volume periods, necessitating parameter adjustments.
Key Features and Functionality
Purpose:
The indicator detects bullish Order Blocks (buy zones) and bearish Order Blocks (sell zones) based on a predefined percentage price movement (default 0.5–1%) and volume confirmation.
It marks these zones on the chart with colored boxes and provides alerts when an OB is detected.
User-Configurable Inputs:
Price Move Range: minMovePercent (default 0.5%) and maxMovePercent (default 1.0%) define the acceptable price movement range for identifying OBs.
Volume Threshold: volumeThreshold (default 1.5x average volume) ensures OB detection is backed by significant trading activity.
Lookback Period: lookback (default 10 candles) determines how many previous candles are analyzed to find the last candle before a strong move.
Wick/Body Option: useWick (default false) allows users to choose whether the OB zone is based on the candle’s wick or body.
Colors: bullishOBColor (default green) and bearishOBColor (default red) set the visual appearance of OB boxes.
Box Extension: boxExtension (default 100 bars) controls how far the OB box extends to the right on the chart.
RSI Filter: useRSI (default true) enables an RSI filter, with rsiLength (default 14), rsiBullishThreshold (default 50), and rsiBearishThreshold (default 50) for trend confirmation.
M15 Support/Resistance: useSR (default true) and srLookback (default 20) integrate M15 timeframe swing highs and lows for additional OB validation.
Core Logic:
Bullish OB Detection: Identifies a strong upward move (0.5–1%) with volume above the threshold. It then looks back to the last bearish candle before the move to define the OB zone. RSI > 50 and proximity to M15 support/resistance (optional) enhance confirmation.
Bearish OB Detection: Identifies a strong downward move (0.5–1%) with volume confirmation, tracing back to the last bullish candle. RSI < 50 and M15 resistance proximity (optional) add validation.
The OB zone is drawn as a rectangle from the high to low of the identified candle, extended rightward.
Visual Output:
Boxes: Uses box.new to draw OB zones, with left set to the previous bar (bar_index[1]), right extended by boxExtension, top and bottom defined by the OB’s high and low prices. Each box includes a text label ("Bullish OB" or "Bearish OB") and is semi-transparent.
Colors distinguish between bullish (green) and bearish (red) OBs.
Alerts:
Global alertcondition definitions trigger notifications for "Bullish OB Detected" and "Bearish OB Detected" when the respective conditions are met, displaying the current close price in the message.
Helper Functions:
f_priceChangePercent: Calculates the percentage price change between open and close prices.
isNearSR: Checks if the price is within 0.2% of M15 swing highs or lows for support/resistance confluence.
How It Works
The script runs on each candle, evaluating the current price action against the user-defined criteria.
When a bullish or bearish move is detected (meeting the percentage, volume, RSI, and S/R conditions), it identifies the preceding candle to define the OB zone.
The OB is then visualized on the chart, and an alert is triggered if configured in TradingView.
Use Case
This indicator is tailored for your BTC scalping strategy, where trades last 1–15 minutes targeting 0.3–0.5% gains. It helps traders spot institutional order zones on the M5 chart, confirmed by secondary M1 analysis, and integrates with your use of EMAs, RSI, and volume. The customizable settings allow adaptation to varying market conditions or personal preferences.
Limitations
The M15 S/R detection is simplified (using swing highs/lows), which may not always align perfectly with manual support/resistance levels.
Alerts depend on TradingView’s alert system and require manual setup.
Performance may vary with high volatility or low-volume periods, necessitating parameter adjustments.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.