OPEN-SOURCE SCRIPT
Order Flow - Multi-TF BOS

Order Flow — Multi-TF BOS
Overview
Multi-timeframe order flow indicator that tracks market structure using Break of Structure (BOS) analysis. Displays a real-time table showing bullish/bearish bias across 4 configurable timeframes, and draws BOS/MSS/CHOCH structure marks directly on the chart.
Features
Multi-Timeframe Order Flow Table
- Shows order flow direction (BULLISH/BEARISH) for 4 timeframes simultaneously (default: 15m, 1h, 4h, 1D)
- All timeframes are configurable — works on any chart timeframe
- Color-coded cells for instant visual read of market bias alignment
- Anti-repainting: uses confirmed bars only (lookahead_off)
Break of Structure Visual Marks
- Draws horizontal lines from the swing point to the break bar at the broken swing price level
- Labels each break as BOS (trend continuation), MSS (Market Structure Shift — first counter-trend break), or CHOCH (Change of Character — confirmed reversal)
- Line styles distinguish break type: BOS = solid, MSS = dashed, CHOCH = solid thick
- Bullish breaks labeled above, bearish breaks labeled below
Structure Detection
- Swing highs and lows detected using pivot logic with configurable lookback (pivot bars)
- Close-based breaks only — no wick-through triggers, reducing false signals
- Two trend modes:
- MSS/CHOCH two-step flip (default): direction only changes after two consecutive counter-trend breaks, filtering noise
- Simple mode: direction flips immediately on any counter-trend break
- Broken swings are consumed to prevent re-triggering
- Optional strict pivot detection mode for precise swing identification
Inputs
Timeframes: 4 configurable timeframe selectors (default: 15m, 1h, 4h, 1D) with individual show/hide toggles
Swing Detection: Pivot bars (default 2), strict pivot mode toggle
Trend Mode: MSS/CHOCH two-step flip toggle
Structure Marks: Independent show/hide for BOS, MSS, and CHOCH. Per-type colors for bullish and bearish breaks (6 color inputs). Per-type line widths. Configurable label size and max marks displayed (default 50).
Table Style: Position, text size, bullish/bearish colors, header background, text color
How It Works
The indicator detects swing highs and swing lows using pivot analysis. When price closes beyond a tracked swing level, it classifies the break:
- BOS: Break in the direction of the current trend (continuation)
- MSS: First break against the current trend (puts trend in a "questioning" state)
- CHOCH: Second break against the trend after an MSS (confirms the reversal and flips direction)
The table evaluates this logic independently on each configured timeframe using request.security(), giving you a multi-timeframe view of market structure alignment. Structure marks are drawn on the current chart timeframe only.
Usage Tips
- Use the table to confirm multi-timeframe alignment before taking trades
- MSS marks serve as early warning of potential trend changes
- CHOCH marks confirm the reversal — useful for timing entries
- Increase pivot bars for higher timeframes to filter noise
- Toggle off BOS marks if you only want to see reversals (MSS/CHOCH)
Overview
Multi-timeframe order flow indicator that tracks market structure using Break of Structure (BOS) analysis. Displays a real-time table showing bullish/bearish bias across 4 configurable timeframes, and draws BOS/MSS/CHOCH structure marks directly on the chart.
Features
Multi-Timeframe Order Flow Table
- Shows order flow direction (BULLISH/BEARISH) for 4 timeframes simultaneously (default: 15m, 1h, 4h, 1D)
- All timeframes are configurable — works on any chart timeframe
- Color-coded cells for instant visual read of market bias alignment
- Anti-repainting: uses confirmed bars only (lookahead_off)
Break of Structure Visual Marks
- Draws horizontal lines from the swing point to the break bar at the broken swing price level
- Labels each break as BOS (trend continuation), MSS (Market Structure Shift — first counter-trend break), or CHOCH (Change of Character — confirmed reversal)
- Line styles distinguish break type: BOS = solid, MSS = dashed, CHOCH = solid thick
- Bullish breaks labeled above, bearish breaks labeled below
Structure Detection
- Swing highs and lows detected using pivot logic with configurable lookback (pivot bars)
- Close-based breaks only — no wick-through triggers, reducing false signals
- Two trend modes:
- MSS/CHOCH two-step flip (default): direction only changes after two consecutive counter-trend breaks, filtering noise
- Simple mode: direction flips immediately on any counter-trend break
- Broken swings are consumed to prevent re-triggering
- Optional strict pivot detection mode for precise swing identification
Inputs
Timeframes: 4 configurable timeframe selectors (default: 15m, 1h, 4h, 1D) with individual show/hide toggles
Swing Detection: Pivot bars (default 2), strict pivot mode toggle
Trend Mode: MSS/CHOCH two-step flip toggle
Structure Marks: Independent show/hide for BOS, MSS, and CHOCH. Per-type colors for bullish and bearish breaks (6 color inputs). Per-type line widths. Configurable label size and max marks displayed (default 50).
Table Style: Position, text size, bullish/bearish colors, header background, text color
How It Works
The indicator detects swing highs and swing lows using pivot analysis. When price closes beyond a tracked swing level, it classifies the break:
- BOS: Break in the direction of the current trend (continuation)
- MSS: First break against the current trend (puts trend in a "questioning" state)
- CHOCH: Second break against the trend after an MSS (confirms the reversal and flips direction)
The table evaluates this logic independently on each configured timeframe using request.security(), giving you a multi-timeframe view of market structure alignment. Structure marks are drawn on the current chart timeframe only.
Usage Tips
- Use the table to confirm multi-timeframe alignment before taking trades
- MSS marks serve as early warning of potential trend changes
- CHOCH marks confirm the reversal — useful for timing entries
- Increase pivot bars for higher timeframes to filter noise
- Toggle off BOS marks if you only want to see reversals (MSS/CHOCH)
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.