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)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.