OPEN-SOURCE SCRIPT
更新済

Support & Resistance with MA Ribbons LITE

1 184
Support & Resistance with MA Ribbons LITE is a chart overlay that combines a fully configurable Moving Average Ribbon with a pivot-based Support & Resistance engine into a single, performance-optimized indicator. The MA Ribbon defines the prevailing trend regime; the S/R engine marks the price levels most likely to generate reactions within that regime. Used together, they provide both directional context and horizontal market structure in one uncluttered overlay.

This script is open-source under the Mozilla Public License 2.0. Parts of the MA Ribbon logic draw conceptual inspiration from publicly shared work by JustUncleL on TradingView — full credit and thanks are extended for those contributions.

═══════════════════════════════════════════

█ WHY COMBINE THESE TWO SYSTEMS?

Most MA ribbon and S/R indicators operate independently. This script was built specifically around their interaction: a support level in a downtrend carries different weight than the same level in an uptrend. The color system, alert logic, and display behavior are all designed so that the two components reinforce each other rather than adding chart clutter.

Original features that do not exist in either component alone:
  • Minute-based anchor timeframe logic — MA lengths scale automatically to preserve the same trend structure across chart timeframes without manual recalculation
  • Mixed Source mode — Main and Strong S/R levels use wicks (High/Low) for accurate reaction zones; secondary levels use Close prices for cleaner signals
  • 6-tone bar coloring — distinguishes bullish/bearish candles inside vs. outside the ribbon, adding nuance beyond a standard 2-color system
  • Smart label contrast — label text color is calculated automatically from background brightness using a weighted luminance formula (0.299·R + 0.587·G + 0.114·B), ensuring legibility across all color presets
  • S/R heat map — line opacity scales with historical touch count, making frequently tested zones visually prominent
  • Alert cooldown system — configurable minimum-bars-between-alerts prevents repeated notifications during consolidation near a level


═══════════════════════════════════════════

█ COMPONENT 1 — MA RIBBON SYSTEM

The ribbon consists of two independently configurable moving averages (Fast and Slow) with 13 supported calculation types:
スナップショット
EMA · SMA · WMA · VWMA · SMMA · DEMA · TEMA · LAGMA · LINREG · HullMA · ZEMA · TMA · SSMA

How the ribbon works:
  • Ribbon fills bullish when Fast MA is above Slow MA, bearish when below
  • Bar coloring reflects whether price is above both MAs (bullish zone), below both (bearish zone), or inside the ribbon (neutral / transitioning)
  • Optional 6-tone mode further distinguishes candles by close vs. open relationship within each zone


Anchor Timeframe Logic (minutes):

Setting an anchor (e.g., 60 = 1 hour) causes MA lengths to multiply proportionally so that the same underlying trend structure is visible regardless of which chart timeframe is active. This eliminates the need to reconfigure MA lengths when switching timeframes.
  • Anchor = 0 → uses current chart timeframe lengths as-is
  • Anchor = 60 on a 5-min chart → MA lengths scale ×12 to reflect 1H structure
  • Anchor = 240 on a 15-min chart → MA lengths scale ×16 to reflect 4H structure


Optional signals:
  • Swing arrows — fire when price first enters a new directional zone (filterable by ribbon color or MA slope)
  • MA cross markers — highlight the crossover bar with a background color flash
  • Continuation markers (XBuy / XSell) — identify early-trend momentum bars after a crossover


═══════════════════════════════════════════

█ COMPONENT 2 — SUPPORT & RESISTANCE ENGINE

Levels are derived from pivot structure analysis — price extremes confirmed by a configurable number of bars to the left and right. The system separates levels by confirmation speed:
スナップショット
⚡ Main Resistance / Support — Fast pivots (quick_right bars). Most recent, reactive levels.
Strong Resistance / Support — Confirmed pivots (right bars). Structurally significant levels.
Resistance 1–4 / Support 1–4 — Historical confirmed pivots. Provides depth and context.

Up to 12 levels can be displayed simultaneously.

Pivot Sensitivity Presets:
  • Scalp — Left: 20 / Right: 10 — Short-term, high-frequency charts
  • Intraday — Left: 30 / Right: 15 — Intraday sessions
  • Swing — Left: 50 / Right: 25 — Multi-day position context
  • Custom — Full manual control over all pivot parameters


Source Modes:
  • High/Low — All levels use candle wicks; captures full reaction range
  • Close — All levels use closing prices; reduces noise from wicks
  • Mixed (Wick/Close) — Main and Strong levels use High/Low; levels 5–12 use Close. Combines precise major zones with cleaner minor levels.


Multi-Timeframe (MTF) Mode:
Higher-timeframe S/R levels can be overlaid on the current chart. HTF data is requested using barmerge.lookahead_off, which means levels update only after each HTF bar closes — no lookahead bias on historical bars.

Strength Filter & Heat Map:
  • Strength filter — hides any level with fewer than N historical touches within a configurable lookback window
  • Heat map mode — line opacity scales proportionally to touch count; the more a level has been tested, the more visually prominent it becomes


═══════════════════════════════════════════

█ ALERT SYSTEM

Six configurable event types:
  • スナップショット
  • ⚡ Main Resistance / Support Touch — Close within tolerance % of level
  • 🎯 Strong Resistance / Support Touch — Close within tolerance % of strong level
  • 🚀 Breakout Above Main Resistance — Close exceeds level × (1 + min breakout %)
  • 📉 Breakdown Below Main Support — Close falls below level × (1 − min breakout %)
  • 🔁 Retest of Broken Level — Price returns to a previously broken level from the correct side
  • ♻️ Rejection at Level — Wick pierces level but close returns inside


Cooldown logic: A minimum-bars-between-alerts setting prevents the same alert from firing repeatedly during sideways price action near a level. Set to 0 to disable.

All alerts are informational and should be visually validated before acting.

═══════════════════════════════════════════

█ COLOR SYSTEM

A unified 5-preset + Custom color palette controls both the MA Ribbon and S/R lines simultaneously, ensuring visual consistency across the indicator.
スナップショット
Presets: Classic · Aqua · Cosmic · Ember · Neon · Custom

Ribbon opacity and bar/candle opacity are independently adjustable. In Custom mode, all 7 color slots are individually configurable (Bullish, Bearish, Neutral, Bullish 2, Bearish 2, Bull Candle, Bear Candle).

═══════════════════════════════════════════

█ HOW TO USE

1. Chart Setup
Add the indicator to any chart and timeframe. Both systems are enabled by default and can be toggled independently via Master Controls.

2. Set the correct Color Preset
Open Settings → 🎨 Color Settings and select the Color Preset that best suits your chart theme (Classic, Aqua, Cosmic, Ember, Neon, or Custom). Both the MA Ribbon fill and all S/R level colors will update simultaneously. Adjust Ribbon Opacity and Bar Opacity to match your preferred visual weight.

3. Bring the indicator to front
スナップショット
This indicator uses plotcandle to render color-coded bars directly on the price chart. If other indicators or chart overlays are layered on top, the colored candles, S/R lines, and MA ribbon may appear behind them and render incorrectly.

To ensure all elements display with full color accuracy:
  • Right-click on the indicator name label on the chart (the label that reads "S/R with MA Ribbons LITE...")
  • Select "Visual Order""Bring to Front"


This places the indicator's candles, S/R lines, and MA ribbon above all other chart elements, ensuring colors render exactly as configured. This setting is saved per chart layout and only needs to be done once.

4. MA Ribbon — Trend Context
  • Price above both MAs → bullish regime; bias longs, watch support levels
  • Price below both MAs → bearish regime; bias shorts, watch resistance levels
  • Price inside ribbon → transitioning; reduce exposure, wait for confirmation
  • Use the Anchor Timeframe to lock ribbon behavior to a reference timeframe (e.g., 240 for 4H structure on any intraday chart)


5. Support & Resistance — Structure
  • Focus on price behavior around levels, not exact prices
  • ⚡ Main levels are the most reactive; Strong levels carry more structural weight
  • Enable Strength Filter to reduce noise from weakly tested levels
  • Enable Heat Map to visually identify the most interacted zones
  • Use MTF mode to overlay daily or weekly structure on lower timeframe charts


6. Reading Both Systems Together
  • In uptrends → reactions near support are higher-probability continuation setups
  • In downtrends → reactions near resistance are higher-probability continuation setups
  • Breakouts above resistance are more significant when ribbon is bullish
  • Retests of broken levels gain confirmation weight when ribbon direction agrees


7. Alerts (optional)
  • Configure alert types in S/R Alert Settings
  • Set Min Bars Between Alerts to match your instrument's typical volatility
  • Always visually confirm before acting on any alert


═══════════════════════════════════════════

█ PERFORMANCE NOTES
  • Touch count loops (Strength Filter / Heat Map) only execute when enabled
  • Reduce Number of Levels to 4–6 on lower-end systems or very fast timeframes
  • Disabling unused features (swing arrows, MA cross markers) improves rendering speed


═══════════════════════════════════════════

█ OPEN SOURCE & CREDITS

This script is released open-source under the Mozilla Public License 2.0.

Parts of the MA Ribbon calculation logic draw conceptual inspiration from publicly shared work by JustUncleL on TradingView. Respect and thanks are extended for those contributions.

You are free to study the code, modify it for personal use, and share improvements under the same license terms.

═══════════════════════════════════════════

█ DISCLAIMER

This indicator is provided for educational and informational purposes only. It does not constitute financial advice, trading recommendations, or investment guidance of any kind. No guarantees are made regarding accuracy, performance, or outcomes. Use at your own discretion alongside independent analysis and appropriate risk management.
リリースノート
RELEASE NOTES

v1.1 — May 2026
🔧 Fix: Runtime error on low timeframes with Anchor Timeframe enabled

A runtime error occurred when adding the indicator to 1-minute (or other very low timeframe) charts while the Anchor Timeframe setting was active.

Root cause:
The Anchor Timeframe logic multiplies MA lengths proportionally to replicate a higher timeframe's trend structure on lower timeframe charts. On a 1-minute chart with Anchor = 60 (1 hour), the multiplier becomes ×60. With larger MA length inputs (e.g. Slow MA = 120), this produces lengths such as 120 × 60 = 7200 — which exceeds TradingView's hard limit of 5000 historical bars for indicator functions like ta.ema, ta.sma, ta.wma etc., causing the script to crash with:

"Error on bar 0: The 'ema'->'sum' function references too many historical candles (7200), the limit is 5000."

Fix applied:
Both LengthFast and LengthSlow are now capped at 4999 — TradingView's safe maximum — regardless of the anchor multiplier or MA length inputs. The indicator now loads correctly on all timeframes, including 1-minute charts, without any runtime errors.

v1.0 — May 2026
Initial publication.
  • MA Ribbon system with 13 MA types and anchor timeframe logic
  • Support & Resistance engine with up to 12 pivot-based levels
  • Mixed Source mode (Wick/Close hybrid) for S/R levels
  • Heat map and Strength Filter for S/R zones
  • Multi-timeframe S/R with barmerge.lookahead_off (no lookahead bias)
  • Unified 5-preset color system with smart label contrast
  • Full alert framework with cooldown logic

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。