OPEN-SOURCE SCRIPT
Cập nhật Impulse Zone Detector

Here's a solid TradingView publish description for the script:
---
**Impulse Zone Detector**
Automatically detects impulsive price moves and marks the origin candle as a supply/demand zone — giving you time to prepare your entry *before* price retraces back to the zone.
**How it works**
When price makes a strong consecutive move in one direction (the impulse), the indicator marks the last opposing candle before that move as a zone. This candle represents the origin of the impulse — a level where price is likely to react when retested. The zone is drawn the moment the impulse completes, so you have maximum preparation time before any retracement occurs.
**Features**
- Detects both bullish and bearish impulse zones automatically
- Zones drawn from candle body only — no wick noise
- EMA filter (default 200) — only draws bearish zones below EMA and bullish zones above EMA, keeping you aligned with the dominant trend
- EMA filter is toggleable — disable to see all valid zones regardless of trend bias
- Mixed candle tolerance — allows minor interruptions in the impulse sequence so valid moves aren't missed
- Duplicate zone prevention — same pivot candle never draws twice
- On-chart dashboard showing current EMA bias, filter status and EMA value
- Full alert support — get notified the moment a zone forms, on any pair and timeframe
**Settings**
- Min/Max impulse candles — control how many consecutive candles define a valid impulse
- Min impulse size multiplier — total move must be a multiple of the pivot candle size
- Min pips — absolute minimum move size to filter out noise
- Mixed candle tolerance — allow 0, 1 or 2 non-conforming candles in the sequence
- EMA length — defaults to 200, fully adjustable
**How to use**
Add to your chart on your preferred timeframe. Set up alerts using the built-in alert conditions so you get notified when a new zone forms. When alerted, switch to that chart, assess the context, and prepare your entry for when price retraces into the marked zone.
Works best on forex pairs on the 5 minute, 15 minute and 1 hour timeframes.
---
Clean, informative and honest about what it does without overpromising. Want me to adjust the tone, add anything, or shorten it?
---
**Impulse Zone Detector**
Automatically detects impulsive price moves and marks the origin candle as a supply/demand zone — giving you time to prepare your entry *before* price retraces back to the zone.
**How it works**
When price makes a strong consecutive move in one direction (the impulse), the indicator marks the last opposing candle before that move as a zone. This candle represents the origin of the impulse — a level where price is likely to react when retested. The zone is drawn the moment the impulse completes, so you have maximum preparation time before any retracement occurs.
**Features**
- Detects both bullish and bearish impulse zones automatically
- Zones drawn from candle body only — no wick noise
- EMA filter (default 200) — only draws bearish zones below EMA and bullish zones above EMA, keeping you aligned with the dominant trend
- EMA filter is toggleable — disable to see all valid zones regardless of trend bias
- Mixed candle tolerance — allows minor interruptions in the impulse sequence so valid moves aren't missed
- Duplicate zone prevention — same pivot candle never draws twice
- On-chart dashboard showing current EMA bias, filter status and EMA value
- Full alert support — get notified the moment a zone forms, on any pair and timeframe
**Settings**
- Min/Max impulse candles — control how many consecutive candles define a valid impulse
- Min impulse size multiplier — total move must be a multiple of the pivot candle size
- Min pips — absolute minimum move size to filter out noise
- Mixed candle tolerance — allow 0, 1 or 2 non-conforming candles in the sequence
- EMA length — defaults to 200, fully adjustable
**How to use**
Add to your chart on your preferred timeframe. Set up alerts using the built-in alert conditions so you get notified when a new zone forms. When alerted, switch to that chart, assess the context, and prepare your entry for when price retraces into the marked zone.
Works best on forex pairs on the 5 minute, 15 minute and 1 hour timeframes.
---
Clean, informative and honest about what it does without overpromising. Want me to adjust the tone, add anything, or shorten it?
Phát hành các Ghi chú
Impulse Zone DetectorAutomatically detects impulsive price moves and marks the origin candle as a supply/demand zone — giving you time to prepare your entry before price retraces back to the zone.
How it works
When price makes a strong consecutive move in one direction (the impulse), the indicator marks the last opposing candle before that move as a zone. This candle represents the origin of the impulse — a level where price is likely to react when retested. The zone is drawn the moment the impulse completes, so you have maximum preparation time before any retracement occurs.
An alert fires immediately when a new zone is created, so you don't need to watch the chart constantly. When alerted, open the chart, assess the context, and prepare your entry for when price retraces into the marked zone.
Features
- Detects both bullish and bearish impulse zones automatically
- Zones drawn from candle body only — no wick noise
- Dynamic impulse scanning — detects valid patterns from 2 up to your defined maximum consecutive candles, so short and extended impulses are both caught
- Mixed candle tolerance — allows minor interruptions in the impulse sequence so valid moves with one or two doji/opposing candles aren't missed
- EMA filter (default 200) — only draws bearish zones below EMA and bullish zones above EMA, keeping you aligned with the dominant trend
- EMA filter is fully toggleable — disable to see all valid zones regardless of trend bias
- EMA line drawn directly on chart with customisable colour
- Duplicate zone prevention — the same pivot candle never draws twice
- On-chart dashboard showing current EMA bias, filter status, EMA value, and current pair/timeframe — toggleable and available in four sizes: Tiny, Small, Normal, Large
- Zone labels toggleable independently for bull and bear zones
- Full alert support — get notified the moment a zone forms on any pair and timeframe
Settings
- Min/Max impulse candles — control the range of consecutive candles that define a valid impulse (default 2–6)
- Min impulse size multiplier — total move must be a set multiple of the pivot candle size (default 3x)
- Min pips — absolute minimum move size to filter out noise (default 10 pips)
- Mixed candle tolerance — allow 0, 1 or 2 non-conforming candles in the impulse sequence
- EMA length — defaults to 200, fully adjustable
- Use EMA filter — toggle trend bias filtering on or off
- Dashboard size — Tiny, Small, Normal or Large
- Customisable zone colours for bull and bear zones
How to use
Add the indicator to your chart on your preferred timeframe and pair. Set up TradingView alerts using the built-in alert conditions — one for bull zones, one for bear zones. When an alert fires, switch to that chart, check the dashboard for current bias, and set up your entry for when price retraces into the marked zone.
Works best on forex pairs on the 5 minute, 15 minute and 1 hour timeframes.
Phát hành các Ghi chú
Fixed when some candles close to Doji would not de set as valid zone. Phát hành các Ghi chú
v1.1 — Update NotesSeveral refinements to zone detection accuracy and usability:
Doji pivot tolerance — Added a configurable doji threshold (default 0.5 pips). Pivot candles with a body smaller than this threshold are now accepted regardless of colour, preventing valid zones from being missed when the pivot candle is a doji or near-flat candle.
Min pips default lowered to 8 — Reduced from 10 to 8 pips default to better capture valid impulse moves on 5 minute timeframes without sacrificing noise filtering.
Dashboard size control — Dashboard is now available in four sizes: Tiny, Small, Normal and Large, selectable from settings.
Dashboard fully toggleable — Turning off the dashboard now completely removes it from the chart rather than leaving an empty panel.
Zone label toggles — Bull and bear zone labels can now be toggled independently, keeping charts clean while still showing zone boxes.
EMA filter timing fix — EMA position is now evaluated at the time of the pivot candle rather than the current bar, preventing zones from being drawn on the wrong side of the EMA when price crosses during or after the impulse.
Phát hành các Ghi chú
v1.2 — Update NotesDynamic zone box width — Zone boxes no longer have a fixed right extension. A new "Zone box width (bars)" setting (default 50, max 500) lets you control exactly how far each zone extends to the right, so you can match your preferred chart style.
Separate fill and border colours — Bull and bear zones now each have two independent colour pickers — one for the fill and one for the border. Previously only the fill colour was adjustable.
Phát hành các Ghi chú
Minor tweaks to defaultsPhát hành các Ghi chú
v1.3 — Update NotesRetracement alerts — The indicator now monitors all active zones and fires a second alert when price returns to a previously created zone. Two trigger modes available: "Enters zone" (price closes inside the zone box) or "Approaches zone" (price comes within a configurable pip distance of the zone boundary).
Alert once per zone — Optional setting to limit each zone to a single retracement alert, preventing repeated alerts if price bounces in and out of the same zone.
Zone invalidation on breakout — When enabled, zones are automatically deactivated if price closes fully through them, keeping monitoring focused on zones that are still relevant.
Active zone counter — Dashboard now shows how many zones are currently being monitored for retracement.
Retracement alert status — Dashboard now shows whether retracement alerts are enabled or disabled.
Phát hành các Ghi chú
**v1.4 — Update Notes**
**EMA bias filter for retracement alerts** — Retracement alerts now respect the current EMA bias. Bull zone retracement alerts only fire when price is above the EMA, and bear zone alerts only fire when price is below. This prevents old zones created under a previous bias from generating misleading alerts after market conditions have changed.
**EMA filter on retracement is independently toggleable** — A new "EMA filter on retracement alerts" setting lets you disable this filter separately from the zone drawing filter, giving full flexibility over alert behaviour.
---
Phát hành các Ghi chú
**v1.6 — Update Notes**Major overhaul of retracement alert reliability, addressing alerts firing too early or not at all:
**Wick-based touch detection** — Retracement alerts now trigger on the candle's high/low instead of only the close. Zones that price wicks into and rejects from — previously missed entirely — now alert correctly.
**Approach mode gap fix** — "Approaches zone" now also triggers when price moves directly into the zone. Fast single-candle moves can no longer skip over the approach band without alerting.
**Zone arming** — New "Arm distance (pips)" setting (default 10). Price must first close a set distance away from a newly created zone before its retracement alert becomes active. This eliminates premature alerts from noise immediately after zone creation and ensures only genuine departure-and-return moves fire. Set to 0 for previous behaviour.
**Armed zone counter** — Dashboard now shows how many active zones are armed and ready to alert, e.g. "10 (7 armed)".
Note: The rejection detection introduced in v1.5 also respects the new arming logic.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.