PROTECTED SOURCE SCRIPT

Grandoc's MTF Separators

40
OverviewThis indicator, known as Grandoc's MTF Separators, draws vertical lines to mark key period boundaries across multiple timeframes (MTF—standing for "Multi-Timeframe," which allows visualization of higher-timeframe structures like daily or weekly pivots directly on lower-timeframe charts, such as 15-minute views). It helps traders align intraday decisions with broader market cycles. Additionally, it includes optional session open/close lines and closing price ranges for major forex sessions (Sydney, Tokyo, Frankfurt, London, New York). By combining customizable timeframe separators with session-specific visuals, it provides a comprehensive tool for multi-timeframe analysis without cluttering the chart. The script is optimized for efficiency, using arrays to manage drawings and respect TradingView's limits.© grandoc
Created: October 12, 2025
Last Modified: October 12, 2025
Version: 1.4 (Improved: Added Frankfurt session with independent toggles for open/close lines and closing range)Key FeaturesMulti-Timeframe (MTF) Separators: Configurable lines for up to four timeframes (e.g., daily, weekly, monthly), plotted as vertical lines extending across the chart. Supports periods from seconds to years—ideal for spotting MTF confluences, like a weekly open aligning with a London session start.
Session Management: Independent toggles for open/close lines and 30-minute closing ranges for five major sessions. Opens use dotted lines by default; closes use solid lines. Frankfurt session added for European traders.
Customization: Select reference points (session start or midnight day start), timezones, colors, line styles, and lookback limits to control visibility and performance.
Efficiency: Arrays limit drawings to user-defined lookback periods, preventing overload on historical data.

Originality and UsefulnessThis script extends standard timeframe detection by integrating session visuals with granular controls, including the new Frankfurt session for better European market coverage. Unlike generic separators, it uses a modular drawSeparator() function for consistent rendering across MTF and sessions, reducing code redundancy. Closing ranges highlight volatility in the final 30 minutes of each session, serving as dynamic support/resistance—unique for session-based strategies.Ideal for forex traders on instruments like EURUSD futures, where aligning intraday trades with higher-timeframe pivots and session transitions reduces noise. For instance, on a 15-minute EURUSD futures chart, daily separators mark session-aligned opens, while London closing ranges flag potential reversal zones before New York handover. The MTF aspect shines here: A weekly separator (orange solid line) crossing a NY open (blue dotted) signals a high-probability setup.How It WorksMulti-Timeframe SeparatorsDetection: Uses ta.change(time(tf, sess, tzz)) to identify period starts, where tf is the timeframe string (e.g., "1D"), sess is "0000-0000" for day-midnight or empty for session-start, and tzz is the timezone.
Drawing: On change, drawSeparator() creates a vertical line via line.new(x1=x_time, x2=x_time, y1=open, y2=open + syminfo.mintick, extend=extend.both). The mintick offset ensures it's a line, not a point. Lines extend both ways for full visibility.
Management: Pushed to dedicated arrays (e.g., sepArray1); excess trimmed with array.shift() and line.delete() based on lookback.
Visibility: Only plots if higher timeframe (timeframe.in_seconds(tf) > timeframe.in_seconds()).

Session Open and Close LinesDetection: For each session (e.g., Sydney: "2200-0700:1234567"), inSession = not na(time(timeframe.period, sessionStr, sessionTz)). Opens trigger on inSession and not inSession[1]; closes on not inSession and inSession[1].
Drawing Opens: Calls drawSeparator(true, sessionColor, sessionOpenWidth, sessionOpenStyle, sessionLookback, sessLinesArray) at time (bar open time). Uses global dotted style/width by default for easy identification of new sessions.
Drawing Closes: Similar call, but at time_close[1] (previous bar close) for precise end-time alignment. Uses global solid style/width. All shared in one sessLinesArray for unified trimming.
Navigation Benefit: Dotted opens act as "entry gates" for session momentum; solid closes as "exit signals." Colors differentiate sessions (e.g., green for Sydney), enabling quick scans—e.g., spot Tokyo open overlaps on EURUSD futures for Asian bias.

Closing RangesDetection: For each closing window (e.g., London: "1630-1700:1234567"), inClose = not na(time(timeframe.period, closeStr, sessionTz)).
Tracking: On entry (inClose and not inClose[1]), initializes high/low at current bar's values and stores bar_index. During session, updates with math.max/min(nz(var, high/low), high/low).
Drawing: On exit (not inClose and inClose[1]), creates box.new(left=startBar, right=bar_index-1, top=high, bottom=low, border_color=sessionColor, bgcolor=color.new(sessionColor, 80)). 80% transparency for subtle shading; border matches session color.
Management: Pushed to rangeBoxesArray; trimmed like lines. Only draws if toggle enabled (defaults off to avoid clutter).
Navigation Benefit: Ranges visually encapsulate end-of-session volatility—e.g., on EURUSD futures, a tight NY range signals low-risk continuation, while wide ones warn of gaps. Ideal for range-break trades or as next-session S/R.

All session elements use the dedicated sessionTz for consistency, independent of separator timezone.Installation and UsageAdd via TradingView's Public Library (search "Grandoc's MTF Separators").
Settings Navigation: Separators (#1-4): Toggle/enable timeframes (e.g., D1 default); lookback hidden for simplicity.
Style: Per-separator colors/widths/styles (hidden widths); global open/close styles for sessions.
Preferences: "Session" vs. "Day" reference (tooltips explain EURUSD example); timezone (hidden, Day-only).
Session Settings: Unified timezone for all sessions.
Open Lines (g4): Per-session toggles (all on default).
Close Lines (g7): Per-session toggles (all on default).
Closing Ranges (g5): Per-session toggles (all off default—enable for S/R focus).
Session Times (g8): Edit strings (e.g., adjust for DST on EURUSD futures).
Colors & Lookback (g6): Session colors; shared lookback limits.

Apply to EURUSD futures (e.g., 15-min chart) with defaults: See green daily dots, orange weekly solids, session opens/closes in theme colors.
Pro Tip: On futures, set "Session" reference and exchange TZ for accurate rollover alignment; enable ranges for close-of-day liquidity plays. For MTF depth, layer #3 (monthly) over intraday for long-term bias.

LimitationsLines/ranges may cluster on low-timeframe charts; increase lookback or disable lower separators.
Session times are UTC defaults; manual DST tweaks needed for futures like EURUSD.
Time-based; avoid non-standard charts (e.g., Renko).
No built-in alerts—use TradingView's on line/box conditions.

Example Chart[Clean EURUSD futures 15-min chart: Green dotted verticals for daily separators at session starts, orange solids for weekly. Dotted opens (e.g., blue NY at 13:00 UTC), solid closes. Faint purple Frankfurt range boxes shading 15:30-16:00 highs/lows. Symbol/timeframe visible in top-left.]Open-source for community reuse (credit © grandoc). Published October 12, 2025. Questions? Comment below!

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.