OPEN-SOURCE SCRIPT
Aktualisiert

Price Memory Heatmap [BullByte]

4 252
Price Memory Heatmap - Dynamic Support & Resistance Through Market Memory

Price Memory Heatmap visualizes where markets remember. It identifies price levels where repeated reactions have occurred, measures their intensity through a proprietary heat system, and displays them as dynamic zones that strengthen with each new reaction and naturally fade when the market moves on.

This is not a combination of existing indicators. It is a unified analytical framework built around one original concept: price levels accumulate heat from confirmed reactions and lose heat through exponential decay when untouched. The result is a self-organizing, self-cleaning map of historically significant price zones that evolves with every bar.

---

WHAT THIS INDICATOR DOES

Price Memory Heatmap tracks price levels where significant market reactions have occurred. Each level is treated as a living entity with memory:

→ Gains heat when price reacts at it (confirmed pivots and wick rejections)
→ Loses heat over time when untouched (exponential decay)
→ Displays visual intensity proportional to accumulated reaction history
→ Gets removed automatically when its heat falls below a minimum threshold
→ Classifies real-time price behavior at each zone (Rejection, Sweep, Break, Retest, Absorption)

The indicator tracks up to 20 memory levels simultaneously and displays only the most significant ones based on heat intensity and reaction count. Zones are color-coded from cool (low activity) to hot (high activity), giving instant visual hierarchy of level importance.

Key outputs:
→ Heat-mapped zones showing historical reaction intensity
→ Classification labels (Developing, Active, Strong, Dominant)
→ Hit count showing total confirmed reactions at each level
→ Relative volume multiplier showing conviction behind reactions
→ Level age tracking (Fresh, Seasoned, Veteran)
→ Real-time behavior detection integrated into zone labels
→ Summary dashboard ranking all active levels by heat

---

WHY THIS INDICATOR EXISTS

Traditional support and resistance tools draw static lines. They cannot tell you whether a level was tested once or ten times, whether reactions were backed by strong volume or weak, whether the level was formed yesterday or months ago, or how price is currently interacting with that level.

Price Memory Heatmap addresses each of these gaps through a single cohesive system:

PROBLEM: "Is this level significant?"
SOLUTION: Heat intensity and classification tier tell you immediately. A Dominant zone with 8 hits is far more significant than a Developing zone with 2 hits.

PROBLEM: "Was there conviction behind reactions at this level?"
SOLUTION: Relative volume multiplier shows whether reactions attracted above-average volume (e.g., 2.3x means 2.3 times the average bar volume).

PROBLEM: "Is this level still relevant?"
SOLUTION: Exponential decay naturally fades untouched levels. If the market has forgotten a level, the indicator forgets it too.

PROBLEM: "How is price interacting with this level right now?"
SOLUTION: Real-time behavior detection classifies the current interaction as Rejection, Sweep, Break, Retest, or Absorption.

PROBLEM: "How old is this level?"
SOLUTION: Age tracking categorizes each level as Fresh (recently formed), Seasoned (survived multiple decay cycles), or Veteran (persistent structural significance).

---

HOW PRICE MEMORY WORKS

The lifecycle of a memory level:

BIRTH - A confirmed pivot swing (high or low) creates a new memory level, or merges into a nearby existing level if one exists within the merge distance.

REINFORCEMENT - Each subsequent reaction at the level adds heat. Reactions with above-average volume add proportionally more heat. The level's price adjusts as a weighted average of all reactions.

DECAY - Every bar without a reaction, the level's heat is multiplied by the decay rate (default 0.992). This creates a natural half-life where untouched levels gradually lose prominence.

DEATH - When heat falls below the death threshold (default 0.08), the level is permanently removed. This keeps the chart clean and focused on relevant levels.

The heat value drives everything:
→ Zone color intensity (hotter = more prominent visual)
→ Classification tier (Dominant, Strong, Active, Developing)
→ Dashboard ranking (sorted by heat, hottest first)
→ Glow effect intensity (stronger glow on high-heat zones near price)

Additionally, wick rejections are detected as secondary reaction sources. When a candle wicks into an existing level and rejects (closes away), it adds heat at half the rate of a confirmed pivot, preventing over-weighting of intrabar noise while still capturing meaningful reactions.

---

WHY THIS IS NOT A MASHUP

This indicator uses pivot detection, ATR, and volume data internally, but it does not combine or display existing indicators. The distinction is fundamental:

A mashup displays independent indicators together on one chart.
This indicator uses standard calculations as INPUT MECHANISMS feeding a completely original processing engine whose output cannot be replicated by any combination of existing tools.

Pivots = Detection mechanism only (identifies where reactions occur)
ATR = Scaling parameter only (normalizes distances across any asset)
Volume = Weighting modifier only (amplifies high-conviction reactions)
Heat Accumulation + Decay = ORIGINAL (no existing indicator does this)
Dynamic Level Lifecycle = ORIGINAL (birth, reinforce, decay, death)
Behavior Detection at Levels = ORIGINAL (classifies interaction patterns)

No component is displayed independently. Everything feeds the central price memory concept.

---

HOW TO READ THE ZONES

ZONE COLORS (Dark Theme - default):
→ Purple/Blue tones = Low heat, Developing level (fewer reactions)
→ Red tones = Medium heat, Active or Strong level
→ Orange/Yellow/Gold tones = High heat, Dominant level (many confirmed reactions)

ZONE COLORS (Light Theme):
→ Gray/Steel tones = Low heat
→ Red/Dark Red tones = Medium to high heat

ZONE COLORS (Classic S/R Theme):
→ Green = Level currently acting as support (price above the zone)
→ Red = Level currently acting as resistance (price below the zone)

ZONE THICKNESS:
Zones expand slightly as heat increases and pulse larger when price approaches (proximity effect). The glow effect adds a soft outer halo that intensifies on high-heat levels near current price, providing immediate visual emphasis on the most important nearby zones.

ZONE LIFESPAN:
Each zone extends from its birth bar to a configurable number of bars into the future (default 15). This visual extension is purely for display - it helps identify where zones project ahead of price. Older zones with maintained heat indicate structural levels where the market has shown persistent memory.

---

HOW TO READ THE LABELS

Each visible zone displays a label with key information. The label format depends on the selected Label Mode. When behavior is detected, it is appended to the end of the label.

MINIMAL MODE EXAMPLE:
"STR 5 2.3x SEA REJ↑"
STR = Classification (Strong)
5 = Hit count (5 confirmed reactions)
2.3x = Relative volume (2.3 times average per reaction)
SEA = Age (Seasoned - 50 to 200 bars old)
REJ↑ = Current behavior (Bullish Rejection detected)

STANDARD MODE EXAMPLE:
"Strong | 5 hits | 2.3x | SEA | Rejection ↑"
→ Full classification name
→ Hit count with label
→ Relative volume multiplier
→ Age abbreviation
→ Full behavior name with direction

DETAILED MODE EXAMPLE:
"Strong | Resistance | 5 | 2.3x | 1.2345 | Seasoned | Sweep ↓"
→ Classification
→ Current support/resistance status
→ Hit count
→ Relative volume
→ Exact price
→ Full age name
→ Full behavior name

LARGE MODE:
Same information as Standard but rendered in larger text for visibility.

When no behavior is currently detected, the behavior portion is simply omitted from the label.

CLASSIFICATION TIERS:
Developing = Heat below 40% of max OR fewer than 3 hits
Active = Heat above 40% AND 3 or more hits
Strong = Heat above 60% AND 4 or more hits
Dominant = Heat above 80% AND 5 or more hits

AGE CATEGORIES:
Fresh (NEW) = Less than 50 bars since first detection
Seasoned (SEA) = Between 50 and 200 bars old
Veteran (VET) = More than 200 bars old

A Veteran level with high heat indicates deep structural significance - a price where the market has reacted repeatedly over an extended period and continues to hold relevance.

RELATIVE VOLUME EXPLAINED:
The volume shown is NOT raw volume. It is a normalized multiplier showing how much volume reactions attracted compared to the average bar:
1.0x = Average volume at reactions
2.0x or higher = Above-average conviction behind reactions
Below 0.5x = Below-average conviction
"-" = Volume data unavailable for this asset

Volume is calculated using attributed notional value: only the fraction of bar volume proportional to the zone width is counted, preventing large-range bars from inflating readings.

---

HOW TO READ THE DASHBOARD

The dashboard provides a ranked summary of all active memory levels. It appears as a table overlay on the chart (position configurable).

COLUMN-BY-COLUMN:

# → Rank by heat intensity. An asterisk (*) marks the highest-heat level. Numbers rank the rest.
PRICE → The exact price of the memory level, formatted to the asset's tick precision. This is the weighted-average price across all reactions at this level.

CLASS → Classification tier (Developing, Active, Strong, Dominant). In Classic S/R theme, a suffix "S" (Support) or "R" (Resistance) is appended based on whether price is above or below the level.

HEAT → Visual heat bar using 8 segments.
→ "||||||||" = Maximum heat (hottest level)
→ "||||...." = Moderate heat
→ "|......." = Low heat (may decay out soon)

HITS → Total number of confirmed reactions at this level. This includes both pivot-confirmed reactions and qualified wick rejections.

RVOL → Relative volume multiplier averaged across all reactions at this level. Higher values indicate stronger volume conviction behind the reactions that built this level.

STATUS → A dynamic field showing one of three things:
→ Behavior pattern name if currently detected (e.g., "REJ↑", "SWP↓", "BRK↑")
→ "At level" if price is within 0.15% of the zone (highlighted in green)
→ Distance as percentage if price is away (e.g., "1.25% above")

AGE → How long the level has existed (NEW, SEA, VET).

FOOTER → Shows total memory levels being tracked, how many are currently visible, and the current decay rate setting.

---

BEHAVIOR DETECTION

When price approaches a memory zone, the indicator analyzes real-time price action to classify how the market is interacting with that level. The detected behavior is displayed as part of the zone label and in the dashboard STATUS column.

Behaviors are checked in priority order. Only the highest-priority match is displayed.

BREAK (Highest Priority):
→ Price opens on one side of the zone and closes decisively on the other
→ Requires strong body (more than 50% of candle range)
→ Close direction must match candle direction (bullish close for Break ↑)
→ Indicates the level has failed and may flip from support to resistance or vice versa
→ Once a Break is detected, the level is marked internally so future Retest detection becomes possible

SWEEP:
→ Price extends significantly beyond the zone (1.5x zone height past the edge) then reverses
→ The extended wick must be larger than the body and more than 35% of total range
→ Close must be back near or inside the zone
→ This pattern often represents a liquidity grab - price pushes through to trigger stops then reverses

REJECTION:
→ A prominent wick touches or enters the zone, and the body closes away
→ Wick must exceed 45% of the candle's total range
→ Body must have meaningful size (more than 25% of range) confirming conviction
→ Indicates the level is actively defending - buyers or sellers are stepping in

RETEST:
→ Price returns to a level that was previously broken
→ Requires all lookback bars to have been on one side (away from zone)
→ Current bar must touch the zone
→ This is the classic "support becomes resistance" or "resistance becomes support" confirmation

ABSORPTION (Lowest Priority):
→ Multiple consecutive bars with bodies inside the zone
→ Average body size is small relative to average range (less than 45%)
→ Indicates accumulation or distribution is occurring within the zone
→ Often precedes significant directional moves

Behaviors persist in the label until a new behavior is detected. When price moves away from the zone, the last detected behavior remains visible, giving context about the most recent significant interaction.

---

RECOMMENDED TIMEFRAMES AND SETTINGS

SCALPING (1-minute to 15-minute charts):
→ Pivot Sensitivity: 2 to 4
→ Decay Rate: 0.980 to 0.985 (faster fade for fast markets)
→ Min Hits: 2
→ Focus on Fresh and Seasoned levels

DAY TRADING (15-minute to 1-hour charts):
→ Pivot Sensitivity: 5 to 8
→ Decay Rate: 0.990 to 0.992 (default range)
→ Min Hits: 2 to 3
→ Balanced mix of age categories

SWING TRADING (4-hour to daily charts):
→ Pivot Sensitivity: 10 to 15
→ Decay Rate: 0.994 to 0.996 (slower fade)
→ Min Hits: 3
→ Focus on Seasoned and Veteran levels

POSITION TRADING (daily to weekly charts):
→ Pivot Sensitivity: 15 to 25
→ Decay Rate: 0.997 to 0.999 (very slow fade)
→ Min Hits: 3 to 4
→ Focus on Veteran levels with high heat

GENERAL TIPS:
→ Higher timeframes benefit from increased Pivot Sensitivity
→ Volatile assets benefit from increased Merge Distance
→ For cleaner charts, increase Min Hits to Display
→ For more context, increase Max Memory Slots and Show Top N Levels

---

PRACTICAL EXAMPLES

EXAMPLE 1 - IDENTIFYING HIGH-PROBABILITY REACTION ZONES:
A Dominant-classified zone (gold/yellow) showing 7 or more hits with Veteran age tells you this is a deeply embedded structural level. The market has reacted here many times over hundreds of bars and the level continues to maintain high heat. When price approaches this zone, the probability of a meaningful reaction is elevated compared to a Developing zone with 2 hits.

EXAMPLE 2 - CONFIRMING A BREAKOUT:
Price approaches a Strong resistance zone. The label updates to show "Break ↑" as price closes decisively above. The dashboard STATUS column changes from "0.5% below" to "BRK↑". If price later returns to this zone and the label shows "Retest ↑", this confirms the classic resistance-to-support flip pattern. The zone's wasBroken flag ensures Retest detection only activates after a confirmed Break.

EXAMPLE 3 - SPOTTING LIQUIDITY SWEEPS:
A high-heat zone sits above price. Price spikes through the zone with a long upper wick but closes back inside or below. The label displays "Sweep ↓" indicating a potential stop-hunt pattern. The wick exceeded 1.5 times the zone height beyond its edge and the upper wick dominated the candle's body - both requirements for Sweep classification.

EXAMPLE 4 - READING VOLUME CONVICTION:
Two zones appear near current price. Zone A shows "2.8x" relative volume while Zone B shows "0.6x". The reactions that built Zone A attracted nearly 3 times the average bar volume, suggesting strong institutional interest. Zone B's reactions occurred on below-average volume, suggesting less conviction. This context helps prioritize which zone is more likely to produce a meaningful reaction.

EXAMPLE 5 - USING LEVEL AGE FOR CONTEXT:
A Veteran level (more than 200 bars old) that still maintains high heat has survived hundreds of decay cycles. Each cycle multiplies its heat by 0.992 (default). After 200 bars of decay without any new reactions, heat would fall to roughly 20% of its peak. For a Veteran level to remain Dominant, it must have received consistent reinforcement over time - indicating genuine structural significance rather than a one-time event.

---
Chart Example

1. Price on the S&P 500 E-mini Futures 15-minute chart is consolidating within a tight range between two heavily-tested Veteran zones, with the gold Dominant level acting as a persistent floor and an orange 22-hit Veteran zone overhead cycling through live behaviors as price repeatedly tests it from below. A structured ladder of purple Developing and red Active zones extends well below current price, with a Retest ↓ pattern visible at a mid-range level indicating a previously broken area is now being revisited from above. The dashboard confirms 17 memory levels tracked with 8 visible, the top-ranked Dominant zone holding a full heat bar and Break ↑ in its STATUS column throughout the session.

Snapshot


2. Price on the Nifty 50 Index 5-minute chart surged strongly through a cluster of high-heat gold zones during the session, reaching a peak at a thin Developing resistance level before pulling back sharply into a contested area between a Dominant zone and a Strong zone sitting just below it. The upper region shows two gold/yellow zones in close proximity - a Dominant and a Strong, both with Sweep behaviors active in their labels, indicating a liquidity grab above followed by a sharp reversal back into the zone cluster. The dashboard shows two Dominant-classified levels in the top two ranks, with a rich mix of Veteran and Seasoned ages confirming this price area carries deep structural memory.

Snapshot
---

SETTINGS REFERENCE

CORE SETTINGS:
Pivot Sensitivity - Bars on each side to confirm a swing. Lower = more sensitive, more levels.
Merge Distance - How close two reactions must be (in ATR multiples) to merge into one level.
ATR Period - Period for volatility normalization (default 14).

MEMORY SETTINGS:
Decay Rate - Per-bar multiplier for heat decay. 0.992 = balanced default.
Heat Per Reaction - Base heat added per confirmed reaction. Modified by volume weighting.
Death Threshold - Minimum heat to survive. Below this, the level is removed.
Max Memory Slots - Maximum simultaneous levels tracked (default 20).
Min Hits to Display - Reactions required before a zone becomes visible (default 2).
Show Top N Levels - Maximum zones rendered on chart (default 8).

DETECTION SETTINGS:
Wick Rejections - Enable wick-based reaction detection (adds heat at half rate of pivots).
Min Wick Ratio - Required wick percentage for wick reactions (default 55%).
Volume-Weighted Heat - Weight reactions by relative volume.
Behavior Detection - Enable real-time pattern classification at zones.
Behavior Lookback - Bars analyzed for behavior patterns (default 3).

APPEARANCE SETTINGS:
Color Theme - Dark (purple to gold gradient), Light (gray to red), Classic S/R (green/red).
Zone Thickness - Visual height of zones as ATR fraction.
Glow Effect - Soft outer halo that intensifies near price.
Proximity Radius - Distance at which proximity effects activate.

LABEL SETTINGS:
Show Zone Labels - Toggle zone information labels.
Label Mode - Information density (Minimal, Standard, Detailed, Large).
Show Hit Count - Include reaction count in labels.
Show Relative Volume - Include volume multiplier in labels.
Reaction Dots - Show dots at exact reaction prices (off by default for chart clarity).

DASHBOARD SETTINGS:
Show Dashboard - Toggle the summary table.
Position - Screen position (8 options).
Text Size - Font size (Tiny, Small, Normal).
Rows - Number of levels shown in dashboard (default 5).

---

ALERTS

Three alert conditions are available:

"Price entered hot zone" - Triggers when price enters a high-heat zone with 3 or more hits and heat above 50% of maximum. Useful for monitoring approaches to significant levels.

"New behavior detected" - Triggers when a new behavior pattern (Rejection, Sweep, Break, Retest, Absorption) is classified at any visible level. Useful for real-time event notification.

"New reaction" - Triggers when a new pivot is confirmed. Useful for tracking all reaction events across all levels.

All alerts describe observed events. They do not predict future price movement or generate buy/sell signals.

---

IMPORTANT NOTES

RETROACTIVE ANCHORING:
Pivot-based levels are confirmed after the Pivot Sensitivity number of bars have passed. The level is drawn at the true swing bar but only becomes known after confirmation. This is standard pivot behavior used across all pivot-based indicators and does not constitute future data usage.

VOLUME DATA AVAILABILITY:
Some assets, particularly certain forex pairs, may not report volume data. When volume is unavailable, relative volume displays show "-" and volume weighting is automatically disabled. The indicator functions fully without volume data.

EARLY CHART BEHAVIOR:
Zones and behavior labels may be sparse early in chart history. The indicator needs sufficient bars to detect pivots, accumulate heat, and meet the minimum hit count. Allow at least 100 bars for the system to populate meaningfully.

PERFORMANCE:
Reaction dots (when enabled) are only rendered within the most recent 500 bars to maintain chart performance. All memory calculations remain unaffected regardless of dot visibility.

---

DISCLAIMER

This indicator is provided for educational and analytical purposes only. It visualizes historical price reaction zones and does not predict future price movement, generate buy/sell signals, or constitute financial advice.

Past reactions at specific price levels do not guarantee future behavior. Market conditions change and levels that held previously may fail in the future. Always conduct your own analysis, use proper risk management, and never risk more than you can afford to lose.

The author assumes no liability for any trading decisions made using this tool. Trading involves significant risk of loss. Use this indicator as one component of a comprehensive trading approach, not as a standalone decision-making system.

---

BullByte
Versionshinweise
Release Notes : v1.1.0

New Feature: Multi-Timeframe (MTF) Support
Lock memory zones to a higher timeframe while viewing lower timeframes for precision entries.

How to Use

1. Open the indicator settings
2. In the CORE group, find "Source Timeframe."
3. Select a higher timeframe (e.g., 1D, 4H, 1W)
4. Drop to your preferred chart timeframe for entries
5. Daily zones remain static on your 15m/1H chart

What's New

New Input:

Source Timeframe : Select the timeframe for memory level detection. Leave blank to use the chart timeframe (default behavior).

MTF Engine:

Memory zones are calculated from the selected higher timeframe
Zones remain static when switching to lower chart timeframes
Pivots, wick reactions, and volume are all sourced from the HTF
Decay only applies once per HTF bar (prevents over-decay)

Visual Indicators:

Zone labels show [1D] prefix (or selected TF) when in MTF mode
Dashboard header displays the source timeframe
Dashboard footer shows TF: 1D when MTF is active


Safety Features:

Warning displayed if source TF ≤ chart TF (invalid configuration)
Warning displayed if source TF is too high (insufficient HTF bars for pivot detection)
Graceful fallback to chart timeframe when configuration is invalid

Technical Notes

HTF data uses request.security() with lookahead = barmerge.lookahead_on for confirmed (non-repainting) data
HTF bar changes are detected using bar open time, not OHLC comparison (more reliable)
Behavior detection still runs on current chart bars for real-time responsiveness

Code Improvements
  1. Added f_createLevel() helper to reduce code duplication
  2. Added f_updateLevel() helper for cleaner reaction processing
  3. Added f_levelVolHTF() for HTF volume attribution
  4. Added f_volWeightHTF() for HTF relative volume weighting
  5. Improved code organization with MTF ENGINE section



Backward Compatibility
Fully backward compatible. When Source Timeframe is left blank (default), the indicator behaves identically to v1.0.0. No existing settings or logic are affected.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.