OPEN-SOURCE SCRIPT
EMA Distance Zone Move Matrix

This indicator answers one of the most practical questions in trading: "When price is X% away from the EMA, how likely is it to move at least Y% from that point?"
It builds a live probability matrix from historical data — no repainting, no predictions — just raw statistics from how price has actually behaved.
How It Works
The indicator measures the percentage distance between price and a selected EMA at every bar. It then groups historical bars into user-defined zones (e.g. "price is 3–5% above EMA") and tracks how often price made a significant move after entering each zone.
Example read:
If the 3 to 5% zone shows ▲≥5%: 62.3% — that means 62.3% of the time, after price entered that zone, it subsequently rallied at least 5% from the entry price within the tracking window.
Settings
EMA
EMA Length — period of the EMA (default: 20)
EMA Timeframe — use the chart timeframe or any higher timeframe
Lookback Bars — how many historical bars to analyse (default: 1000)
Bars to Track — how many bars after zone entry to watch for the move (default: 50)
From Zones (Rows) — 8 zones, each with:
Enable/disable toggle
Lo% and Hi% — the EMA distance band (supports negative values for below-EMA zones)
Label — custom name shown in the table row
Move Thresholds (Columns) — 10 thresholds, each with:
Enable/disable toggle
Direction — ▲ Up (price rises), ▼ Down (price falls), ↕ Either (either direction)
≥ % — minimum move size to count as a hit
Display
Show % or raw count
Heatmap color mode
Table position and text size
The Matrix Table
Rows = FROM zones (where price was when it entered)
Columns = move thresholds (how far it moved after)
Last column = total number of visits to that zone
Each cell shows the probability (%) or count of times price achieved that move after entering that zone.
Color coding (heatmap mode):
Red — highest probability (≥75% of max)
Orange — high (50–75%)
Yellow — moderate (25–50%)
Teal — low (below 25%)
Gray — zero / no data
Column headers are color-coded by direction:
Teal = Up move ▲
Red = Down move ▼
Purple = Either direction ↕
The footer row shows the currently active zone and the indicator settings summary.
Chart Background
The chart background is lightly shaded to show which zone price is currently in — making it easy to spot your current EMA distance zone at a glance without looking at the table.
Use Cases
Find which EMA distance zones historically lead to strong reversals or continuations
Identify asymmetric zones where up-move probability is much higher than down
Compare behavior at oversold vs overbought EMA distances
Build mean-reversion or momentum setups backed by historical statistics
Use with any EMA (20, 50, 100, 200) on any timeframe
Notes
overlay=true — draws directly on the main chart, no separate pane needed
A move is counted once per zone visit per threshold (first time it's hit within the tracking window)
Works on any instrument: stocks, crypto, forex, futures, indices
The matrix updates live on every bar — no need to refresh
Use a lookback of at least 500 bars for statistically meaningful results
Ensure the chart timeframe has enough history to cover the lookback window
Settings Quick Start (recommended defaults):
Zones: -10 to -5 · -5 to -3 · -3 to 0 · 0 to 3 · 3 to 5 · 5 to 10
Moves: ▲≥1% · ▲≥2% · ▲≥5% · ▲≥10% · ▼≥1% · ▼≥2% · ▼≥5% · ▼≥10%
Lookback: 1000 · Track window: 50 bars
It builds a live probability matrix from historical data — no repainting, no predictions — just raw statistics from how price has actually behaved.
How It Works
The indicator measures the percentage distance between price and a selected EMA at every bar. It then groups historical bars into user-defined zones (e.g. "price is 3–5% above EMA") and tracks how often price made a significant move after entering each zone.
Example read:
If the 3 to 5% zone shows ▲≥5%: 62.3% — that means 62.3% of the time, after price entered that zone, it subsequently rallied at least 5% from the entry price within the tracking window.
Settings
EMA
EMA Length — period of the EMA (default: 20)
EMA Timeframe — use the chart timeframe or any higher timeframe
Lookback Bars — how many historical bars to analyse (default: 1000)
Bars to Track — how many bars after zone entry to watch for the move (default: 50)
From Zones (Rows) — 8 zones, each with:
Enable/disable toggle
Lo% and Hi% — the EMA distance band (supports negative values for below-EMA zones)
Label — custom name shown in the table row
Move Thresholds (Columns) — 10 thresholds, each with:
Enable/disable toggle
Direction — ▲ Up (price rises), ▼ Down (price falls), ↕ Either (either direction)
≥ % — minimum move size to count as a hit
Display
Show % or raw count
Heatmap color mode
Table position and text size
The Matrix Table
Rows = FROM zones (where price was when it entered)
Columns = move thresholds (how far it moved after)
Last column = total number of visits to that zone
Each cell shows the probability (%) or count of times price achieved that move after entering that zone.
Color coding (heatmap mode):
Red — highest probability (≥75% of max)
Orange — high (50–75%)
Yellow — moderate (25–50%)
Teal — low (below 25%)
Gray — zero / no data
Column headers are color-coded by direction:
Teal = Up move ▲
Red = Down move ▼
Purple = Either direction ↕
The footer row shows the currently active zone and the indicator settings summary.
Chart Background
The chart background is lightly shaded to show which zone price is currently in — making it easy to spot your current EMA distance zone at a glance without looking at the table.
Use Cases
Find which EMA distance zones historically lead to strong reversals or continuations
Identify asymmetric zones where up-move probability is much higher than down
Compare behavior at oversold vs overbought EMA distances
Build mean-reversion or momentum setups backed by historical statistics
Use with any EMA (20, 50, 100, 200) on any timeframe
Notes
overlay=true — draws directly on the main chart, no separate pane needed
A move is counted once per zone visit per threshold (first time it's hit within the tracking window)
Works on any instrument: stocks, crypto, forex, futures, indices
The matrix updates live on every bar — no need to refresh
Use a lookback of at least 500 bars for statistically meaningful results
Ensure the chart timeframe has enough history to cover the lookback window
Settings Quick Start (recommended defaults):
Zones: -10 to -5 · -5 to -3 · -3 to 0 · 0 to 3 · 3 to 5 · 5 to 10
Moves: ▲≥1% · ▲≥2% · ▲≥5% · ▲≥10% · ▼≥1% · ▼≥2% · ▼≥5% · ▼≥10%
Lookback: 1000 · Track window: 50 bars
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.