OPEN-SOURCE SCRIPT
Meridian Lens PRO

🟦 Meridian Lens PRO is a multi-kernel trend indicator built on the KernelLens Nadaraya–Watson regression library (a_jabbaroff/KernelLens/1). Three independently configurable kernel lines — Fast, Medium, and Slow — cover the full reactivity spectrum from scalping to position trading, each accepting any of the eight kernel families and three filter modes exposed by the library. The visual layer applies volume-intensity-adaptive coloring, gradient-filled trailing bands, 3-layer neon glow signal arrows, and a theme-aware dashboard — all driven by a single theme selection from ten optical-brand palettes.
🟦 HOW IT WORKS
Meridian Lens PRO calls the KernelLens library's unified dispatcher (`kl.estimate`) three times per bar — once for each kernel line:
```
Fast = kl.estimate(type, src, bw=8, α, period, phase, filter)
Medium = kl.estimate(type, src, bw=16, α, period, phase, filter)
Slow = kl.estimate(type, src, bw=32, α, period, phase, filter)
```
Each line independently selects its kernel family (Rational Quadratic, Gaussian, Periodic, Locally Periodic, Epanechnikov, Tricube, Triangular, Cosine), its filter mode (No Filter / Smooth / Zero Lag), its bandwidth, shape α, period, phase, and line width. The library handles all weighted-sum computation, loop-depth selection, NA-safe iteration, and input validation internally.
The Medium line is the primary trend reference — it drives the trailing bands, the main signal arrows, the dashboard trend cell, and the direction variable that colors every visual component. The Fast line provides early-warning reactivity for short-term entry timing. The Slow line anchors the macro trend for crossover logic and confluence scoring.
🟦 KERNEL LIBRARY INTEGRATION
Meridian Lens imports the published KernelLens library and uses the following exports:
| Library Export | Used For |
|---|---|
| `kl.estimate()` | Unified dispatcher — routes to the correct kernel based on user's dropdown selection |
| `kl.trendState()` | Returns +1 / −1 / 0 for each kernel's slope — drives dashboard arrows and signal triggers |
| `kl.crossSignal()` | Detects Fast × Slow crossovers — drives the Cross row in the dashboard and crossover alerts |
The indicator does not reimplement any kernel math — all regression computation is delegated to the library, ensuring that every bug fix or optimization in the library automatically propagates to this indicator.
🟦 THREE KERNEL LINES
**Fast Kernel** — The most reactive line. Default bandwidth 8, No Filter. Designed for scalping and short-term entry timing. Flips direction frequently on noisy charts — its signal markers are OFF by default to avoid visual clutter.
**Medium Kernel** — The primary trend reference. Default bandwidth 16, Smooth filter. Drives the trailing bands, the main 3-layer glow signal arrows, the dashboard Trend cell, and the direction variable that colors every visual component. This is the indicator's core signal.
**Slow Kernel** — The macro trend anchor. Default bandwidth 32, Smooth filter. Provides structural support for crossover logic (Fast × Slow) and triple-line confluence scoring. Its signal markers are ON by default because Slow flips are rare and meaningful.
Each kernel group exposes: Show toggle, Kernel Type dropdown (8 families), Bandwidth, Shape α (RQ only), Period (Periodic / Locally Periodic only), Phase (non-repainting offset), Filter (None / Smooth / Zero Lag), and Line Width.
🟦 NON-REPAINTING BEHAVIOR
Meridian Lens inherits non-repainting behavior directly from the KernelLens library's `_phase` parameter. Each kernel line has its own Phase input (default: 2), which shifts the kernel center into the past by that many bars.
- Phase = 0 — live estimate, flickers on the current bar (real-time only; history is immutable)
- Phase = 1 — 1-bar lag, non-repainting once the bar is confirmed
- Phase = 2 — recommended balance between freshness and stability (default)
- Phase = 3+ — extra stability for swing and position trading
Historical repainting never occurs at any phase value. The library contains no `request.security` calls, no lookahead, and no array rotation that could leak future data. Every historical bar's plotted value is final once confirmed.
🟦 SIGNAL SYSTEM
The indicator produces three tiers of trend-flip signals, each visually distinct:
**Medium Signals (Primary)** — 3-layer neon glow arrows rendered when the Medium kernel's direction flips. The outer halo is large and 80% transparent, the middle layer is normal-sized and 50% transparent, and the core arrow is small and fully opaque — creating a luminous halo effect on dark charts. Controlled by the "Glow Effect" toggle.
**Slow Signals** — Minimal tiny arrows (40% transparent) that fire when the Slow kernel flips direction. ON by default — these mark rare, meaningful macro trend changes.
**Fast Signals** — Minimal tiny arrows (40% transparent) that fire when the Fast kernel flips direction. OFF by default — enable for early-warning entry timing on lower timeframes.
🟦 VISUAL PIPELINE
**Volume-Intensity Adaptive Color** — The Medium line's transparency responds to the current volume reading. High volume = bright line (volume-confirmed trend), low volume = dim line (low-conviction drift). Uses a 33-bar HMA-smoothed normalized volume metric. Disable for a fixed 50% transparency.
**Trailing Bands** — Gradient-filled bands on the bullish/bearish side of the Medium line. Band width is driven by the rolling 100-bar average candle body size multiplied by a configurable distance factor (default: 2.0×). Bull bands fill below the Medium line during uptrends, bear bands fill above during downtrends.
**Theme System** — Ten cohesive palettes drive every visual component:
| Theme | Bull | Bear |
|---|---|---|
| Prism | Forest green | Crimson red |
| Focus | Cyan steel | Deep orange |
| Solar | Warm amber | Indigo red |
| Frost | Sky blue | Soft lavender |
| Laser | Neon lime | Hot crimson |
| Aurora | Bright gold | Scarlet |
| Plasma | Electric aqua | Magenta |
| Bloom | Mint green | Hot pink |
| Eclipse | Deep navy | Dark crimson |
| Carbon | Near-black | Silver grey |
🟦 PRO DASHBOARD
A 2-column, 11-row theme-aware status panel that updates only on the last bar (zero historical overhead). Supports Dark and Light display modes with configurable position and text size.
| Row | Label | Content |
|---|---|---|
| Header | MERIDIAN LENS | DARK / LIGHT |
| Theme | Theme | Active palette name |
| Kernel | Kernel | Medium kernel type |
| Divider | KERNELS | — |
| Fast | Fast | ▲/▼ + price value (bull/bear colored) |
| Medium | Medium | ▲/▼ + price value (bull/bear colored) |
| Slow | Slow | ▲/▼ + price value (bull/bear colored) |
| Divider | SIGNALS | — |
| Trend | Trend | ▲ BULL / ▼ BEAR |
| Cross | Cross | ↑ UP / ↓ DOWN / — |
| Strength | Strength | ▰▰▰ TRIPLE / ▰▰▱ STRONG / ▰▱▱ WEAK / ▱▱▱ NEUTRAL |
**Confluence Strength** — Counts how many of the three kernels (Fast, Medium, Slow) have their trend aligned with the Medium's direction. Score 3 = TRIPLE BULL/BEAR, 2 = STRONG, 1 = WEAK, 0 = NEUTRAL.
🟦 ALERT CONDITIONS
Six opt-in alert conditions, each gated by its own toggle:
| Alert | Fires When |
|---|---|
| Bull Crossover | Fast line crosses above Slow line |
| Bear Crossover | Fast line crosses below Slow line |
| Trend Up | Medium kernel trend flips to rising |
| Trend Down | Medium kernel trend flips to falling |
| Triple Bullish | Fast > Medium > Slow AND Medium rising |
| Triple Bearish | Fast < Medium < Slow AND Medium falling |
All alerts use `alertcondition()` for maximum compatibility with TradingView's alert system including webhooks.
🟦 RECOMMENDED PRESETS
| Style | Fast bw | Med bw | Slow bw | Phase | Med Filter | Chart |
|---|---|---|---|---|---|---|
| Scalper | 4–8 | 8–16 | 16–32 | 1 | No Filter | 1m–5m |
| Day Trader | 8–12 | 14–24 | 24–48 | 2 | Smooth | 15m–1h |
| Swing | 16–24 | 24–40 | 48–80 | 2 | Smooth | 4h–1D |
| Position | 24–48 | 40–80 | 80–200 | 3 | Smooth | 1D–1W |
🟦 COMPATIBILITY
- Pine Script v6
- All exchanges, all asset classes (crypto, forex, equities, commodities)
- All timeframes (1 minute through Monthly)
- No exchange-specific logic — fully deterministic
🟦 TECHNICAL NOTES
- **Library dependency** — `import a_jabbaroff/KernelLens/1` — all kernel regression math is delegated to the library
- **Plot budget** — 5 plots + 2 fills + 10 plotshapes = well under Pine's 64-plot limit
- **Table** — Single `var table` created once on `barstate.islast`, zero historical overhead
- **No persistent drawing objects** — no `box.new`, `label.new`, `line.new` — no garbage collection needed
- **Non-repainting** — inherits from the library's `_phase` parameter; no `request.security`, no lookahead
- **Volume-intensity** — uses HMA-smoothed normalized volume (33-bar window) for adaptive transparency
🟦 DISCLAIMER
Meridian Lens PRO is a technical analysis overlay indicator built on the KernelLens Nadaraya–Watson regression library. It is provided solely for educational and research purposes and does not constitute financial, investment, or trading advice.
Kernel regression is a local smoothing technique. It estimates the mean of a source series in the neighborhood of the current bar based on historical data, but it does not predict future prices, does not generate trading signals on its own, and does not guarantee the profitability of any strategy built on top of its output.
Past performance of any model does not guarantee future results. Markets contain systemic risks that cannot be eliminated by any amount of mathematical rigor. Responsibility for any trading decisions rests entirely with the user. Always apply sound capital management, conduct your own independent analysis, and never risk capital you are not prepared to lose.
The author assumes no liability for direct or indirect losses incurred through the use of Meridian Lens or the underlying KernelLens library.
🟦 HOW IT WORKS
Meridian Lens PRO calls the KernelLens library's unified dispatcher (`kl.estimate`) three times per bar — once for each kernel line:
```
Fast = kl.estimate(type, src, bw=8, α, period, phase, filter)
Medium = kl.estimate(type, src, bw=16, α, period, phase, filter)
Slow = kl.estimate(type, src, bw=32, α, period, phase, filter)
```
Each line independently selects its kernel family (Rational Quadratic, Gaussian, Periodic, Locally Periodic, Epanechnikov, Tricube, Triangular, Cosine), its filter mode (No Filter / Smooth / Zero Lag), its bandwidth, shape α, period, phase, and line width. The library handles all weighted-sum computation, loop-depth selection, NA-safe iteration, and input validation internally.
The Medium line is the primary trend reference — it drives the trailing bands, the main signal arrows, the dashboard trend cell, and the direction variable that colors every visual component. The Fast line provides early-warning reactivity for short-term entry timing. The Slow line anchors the macro trend for crossover logic and confluence scoring.
🟦 KERNEL LIBRARY INTEGRATION
Meridian Lens imports the published KernelLens library and uses the following exports:
| Library Export | Used For |
|---|---|
| `kl.estimate()` | Unified dispatcher — routes to the correct kernel based on user's dropdown selection |
| `kl.trendState()` | Returns +1 / −1 / 0 for each kernel's slope — drives dashboard arrows and signal triggers |
| `kl.crossSignal()` | Detects Fast × Slow crossovers — drives the Cross row in the dashboard and crossover alerts |
The indicator does not reimplement any kernel math — all regression computation is delegated to the library, ensuring that every bug fix or optimization in the library automatically propagates to this indicator.
🟦 THREE KERNEL LINES
**Fast Kernel** — The most reactive line. Default bandwidth 8, No Filter. Designed for scalping and short-term entry timing. Flips direction frequently on noisy charts — its signal markers are OFF by default to avoid visual clutter.
**Medium Kernel** — The primary trend reference. Default bandwidth 16, Smooth filter. Drives the trailing bands, the main 3-layer glow signal arrows, the dashboard Trend cell, and the direction variable that colors every visual component. This is the indicator's core signal.
**Slow Kernel** — The macro trend anchor. Default bandwidth 32, Smooth filter. Provides structural support for crossover logic (Fast × Slow) and triple-line confluence scoring. Its signal markers are ON by default because Slow flips are rare and meaningful.
Each kernel group exposes: Show toggle, Kernel Type dropdown (8 families), Bandwidth, Shape α (RQ only), Period (Periodic / Locally Periodic only), Phase (non-repainting offset), Filter (None / Smooth / Zero Lag), and Line Width.
🟦 NON-REPAINTING BEHAVIOR
Meridian Lens inherits non-repainting behavior directly from the KernelLens library's `_phase` parameter. Each kernel line has its own Phase input (default: 2), which shifts the kernel center into the past by that many bars.
- Phase = 0 — live estimate, flickers on the current bar (real-time only; history is immutable)
- Phase = 1 — 1-bar lag, non-repainting once the bar is confirmed
- Phase = 2 — recommended balance between freshness and stability (default)
- Phase = 3+ — extra stability for swing and position trading
Historical repainting never occurs at any phase value. The library contains no `request.security` calls, no lookahead, and no array rotation that could leak future data. Every historical bar's plotted value is final once confirmed.
🟦 SIGNAL SYSTEM
The indicator produces three tiers of trend-flip signals, each visually distinct:
**Medium Signals (Primary)** — 3-layer neon glow arrows rendered when the Medium kernel's direction flips. The outer halo is large and 80% transparent, the middle layer is normal-sized and 50% transparent, and the core arrow is small and fully opaque — creating a luminous halo effect on dark charts. Controlled by the "Glow Effect" toggle.
**Slow Signals** — Minimal tiny arrows (40% transparent) that fire when the Slow kernel flips direction. ON by default — these mark rare, meaningful macro trend changes.
**Fast Signals** — Minimal tiny arrows (40% transparent) that fire when the Fast kernel flips direction. OFF by default — enable for early-warning entry timing on lower timeframes.
🟦 VISUAL PIPELINE
**Volume-Intensity Adaptive Color** — The Medium line's transparency responds to the current volume reading. High volume = bright line (volume-confirmed trend), low volume = dim line (low-conviction drift). Uses a 33-bar HMA-smoothed normalized volume metric. Disable for a fixed 50% transparency.
**Trailing Bands** — Gradient-filled bands on the bullish/bearish side of the Medium line. Band width is driven by the rolling 100-bar average candle body size multiplied by a configurable distance factor (default: 2.0×). Bull bands fill below the Medium line during uptrends, bear bands fill above during downtrends.
**Theme System** — Ten cohesive palettes drive every visual component:
| Theme | Bull | Bear |
|---|---|---|
| Prism | Forest green | Crimson red |
| Focus | Cyan steel | Deep orange |
| Solar | Warm amber | Indigo red |
| Frost | Sky blue | Soft lavender |
| Laser | Neon lime | Hot crimson |
| Aurora | Bright gold | Scarlet |
| Plasma | Electric aqua | Magenta |
| Bloom | Mint green | Hot pink |
| Eclipse | Deep navy | Dark crimson |
| Carbon | Near-black | Silver grey |
🟦 PRO DASHBOARD
A 2-column, 11-row theme-aware status panel that updates only on the last bar (zero historical overhead). Supports Dark and Light display modes with configurable position and text size.
| Row | Label | Content |
|---|---|---|
| Header | MERIDIAN LENS | DARK / LIGHT |
| Theme | Theme | Active palette name |
| Kernel | Kernel | Medium kernel type |
| Divider | KERNELS | — |
| Fast | Fast | ▲/▼ + price value (bull/bear colored) |
| Medium | Medium | ▲/▼ + price value (bull/bear colored) |
| Slow | Slow | ▲/▼ + price value (bull/bear colored) |
| Divider | SIGNALS | — |
| Trend | Trend | ▲ BULL / ▼ BEAR |
| Cross | Cross | ↑ UP / ↓ DOWN / — |
| Strength | Strength | ▰▰▰ TRIPLE / ▰▰▱ STRONG / ▰▱▱ WEAK / ▱▱▱ NEUTRAL |
**Confluence Strength** — Counts how many of the three kernels (Fast, Medium, Slow) have their trend aligned with the Medium's direction. Score 3 = TRIPLE BULL/BEAR, 2 = STRONG, 1 = WEAK, 0 = NEUTRAL.
🟦 ALERT CONDITIONS
Six opt-in alert conditions, each gated by its own toggle:
| Alert | Fires When |
|---|---|
| Bull Crossover | Fast line crosses above Slow line |
| Bear Crossover | Fast line crosses below Slow line |
| Trend Up | Medium kernel trend flips to rising |
| Trend Down | Medium kernel trend flips to falling |
| Triple Bullish | Fast > Medium > Slow AND Medium rising |
| Triple Bearish | Fast < Medium < Slow AND Medium falling |
All alerts use `alertcondition()` for maximum compatibility with TradingView's alert system including webhooks.
🟦 RECOMMENDED PRESETS
| Style | Fast bw | Med bw | Slow bw | Phase | Med Filter | Chart |
|---|---|---|---|---|---|---|
| Scalper | 4–8 | 8–16 | 16–32 | 1 | No Filter | 1m–5m |
| Day Trader | 8–12 | 14–24 | 24–48 | 2 | Smooth | 15m–1h |
| Swing | 16–24 | 24–40 | 48–80 | 2 | Smooth | 4h–1D |
| Position | 24–48 | 40–80 | 80–200 | 3 | Smooth | 1D–1W |
🟦 COMPATIBILITY
- Pine Script v6
- All exchanges, all asset classes (crypto, forex, equities, commodities)
- All timeframes (1 minute through Monthly)
- No exchange-specific logic — fully deterministic
🟦 TECHNICAL NOTES
- **Library dependency** — `import a_jabbaroff/KernelLens/1` — all kernel regression math is delegated to the library
- **Plot budget** — 5 plots + 2 fills + 10 plotshapes = well under Pine's 64-plot limit
- **Table** — Single `var table` created once on `barstate.islast`, zero historical overhead
- **No persistent drawing objects** — no `box.new`, `label.new`, `line.new` — no garbage collection needed
- **Non-repainting** — inherits from the library's `_phase` parameter; no `request.security`, no lookahead
- **Volume-intensity** — uses HMA-smoothed normalized volume (33-bar window) for adaptive transparency
🟦 DISCLAIMER
Meridian Lens PRO is a technical analysis overlay indicator built on the KernelLens Nadaraya–Watson regression library. It is provided solely for educational and research purposes and does not constitute financial, investment, or trading advice.
Kernel regression is a local smoothing technique. It estimates the mean of a source series in the neighborhood of the current bar based on historical data, but it does not predict future prices, does not generate trading signals on its own, and does not guarantee the profitability of any strategy built on top of its output.
Past performance of any model does not guarantee future results. Markets contain systemic risks that cannot be eliminated by any amount of mathematical rigor. Responsibility for any trading decisions rests entirely with the user. Always apply sound capital management, conduct your own independent analysis, and never risk capital you are not prepared to lose.
The author assumes no liability for direct or indirect losses incurred through the use of Meridian Lens or the underlying KernelLens library.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน