Reaction Entry EngineReaction Entry Engine
Reaction Entry Engine is an open-source supply and demand reaction indicator built around one specific analytical idea:
the first meaningful return into a structurally valid zone can carry different information than later retests of the same area.
This script is not designed to mark every possible touch of every level, and it is not intended to behave like a generic supply and demand overlay that treats repeated interaction the same way. Its purpose is to build supply and demand zones from confirmed pivot structure, optionally validate the strength of the move that created the zone, rank the zone using an internal quality model, detect first-touch reactions, and map those reactions into a structured on-chart framework for analysis and review.
The script also includes review panels so users can inspect how projected setups behaved over time under the current settings. Those review tools are included to support study and comparison, not to imply future performance.
OPEN-SOURCE NOTE
This script is published open-source so users can inspect the logic directly, verify what the script is doing, and adapt parts of the workflow for their own research if they wish.
Even though the code is open, this description is intentionally detailed because many TradingView users do not read Pine Script. The goal is for a user to understand what the script does, how it works, why its parts belong together, and how it may be used in practice without having to study the code line by line.
OVERVIEW
At a high level, the script does six things:
1. It builds supply and demand zones from confirmed pivot structure.
2. It can source those zones from the chart timeframe, from a higher timeframe, or from both.
3. It can filter weak formations by checking whether the move surrounding the pivot had enough directional strength.
4. It can score zone quality using post-formation displacement, reaction behavior, penetration depth, and repeated-touch penalties.
5. It can detect first-touch reactions into valid zones.
6. It can project entry, stop, and target structure on the chart and summarize projected historical behavior in review panels.
The script is therefore meant to function as a complete first-touch zone reaction framework rather than as a single-purpose zone-drawing tool.
CORE IDEA
Many structural tools identify areas where price may react, but they do not distinguish clearly between the first meaningful return into a zone and later repeated interaction with that same area.
This script is built around the idea that those two situations are not necessarily equivalent.
A fresh or relatively intact zone may behave differently from a zone that has already been tested multiple times. Because of that, the script does not treat all contact events in the same way. It attempts to organize the workflow into a more selective sequence:
first identify structure,
then filter weak structure,
then rank remaining zones,
then focus on the earliest qualifying return,
then map that return into a consistent visual framework for review.
This narrower focus is the main reason the script exists in its current form.
WHY THIS SCRIPT IS NOT A SIMPLE MASHUP
This script combines multiple components, but they are not included simply to place more features into one publication.
Each component has a specific function inside the same analytical process:
- Zone construction defines the structural areas.
- Multi-timeframe sourcing expands or narrows the structural map.
- The impulse filter reduces zones formed without meaningful directional expansion.
- The quality engine separates stronger and weaker structural candidates.
- The first-touch logic makes the model more selective than a repeated-touch zone script.
- The projection layer reduces the need for manual chart annotation after a setup appears.
- The review panels allow the user to examine projected historical behavior under the chosen settings.
These layers are interdependent.
Without the zone engine, there is no structural area to evaluate.
Without impulse validation, the model accepts more weak or noisy pivots.
Without quality scoring, all detected zones are treated too similarly.
Without first-touch logic, the script behaves more like a generic touch-based zone tool.
Without the projection layer, the user still has to manually draw entry, stop, and target structure after each setup.
Without the review layer, the user has less organized feedback when comparing settings or reviewing behavior across time.
For that reason, the script is intended as a single first-touch supply and demand reaction framework, not as a random collection of unrelated features.
WHAT THE SCRIPT DOES
The script identifies supply and demand zones from confirmed pivot highs and pivot lows.
Once a zone is created, the script can continue to monitor it and decide whether it should remain only as a structural reference or whether it qualifies for deeper evaluation inside the reaction framework.
Depending on settings, the script can:
- draw supply and demand zones,
- create zones from the chart timeframe,
- create zones from a selected higher timeframe,
- merge nearby zones of the same type,
- classify zones using an internal quality model,
- detect first-touch BUY or SELL reactions,
- project entry, stop loss, and take profit structure,
- retain historical projected trades on the chart,
- summarize projected behavior in performance and daily review panels.
This allows the chart to function not only as a zone map, but also as a structured review environment for the script’s own reaction model.
HOW THE SCRIPT WORKS
1) SUPPLY AND DEMAND ZONE CONSTRUCTION
The script uses pivot highs and pivot lows to define structural areas.
A pivot high can produce a supply zone.
A pivot low can produce a demand zone.
Rather than treating a pivot as one exact price, the script expands the pivot into a zone using a configurable pip-based thickness. This is important because many traders interpret supply and demand as areas rather than as single lines.
The script can build zones from:
- the current chart timeframe,
- a selected higher timeframe,
- or both at the same time.
If nearby zones of the same type are close enough to one another, the script can merge them into a broader structural area. This is meant to reduce overlap and make the displayed structure easier to read.
2) CONFIRMED ZONE LOGIC
The script includes a minimum-touch setting for confirmed zones.
This setting allows users to distinguish between:
- zones that have merely been detected,
- and zones that have accumulated enough interaction to be considered more established.
Different traders interpret this differently. Some prefer relatively fresh zones. Others prefer zones that have already shown repeated market interaction. The script is designed to support both approaches through settings rather than by forcing one interpretation.
3) TOUCH DETECTION
Zone interaction can be recognized using:
- wick touch,
- body touch,
- or both.
This affects how strict or permissive the model is when determining whether price has returned into a zone.
A wick-based model can capture sharp rejections that only briefly enter the area.
A body-based model is stricter and may reduce noise.
Using both provides broader coverage.
This means the same structural framework can be adapted to different preferences without changing the core logic of the script.
4) IMPULSE VALIDATION
Not every pivot represents meaningful structure.
Some pivots are formed during weak, indecisive, or noisy movement. To reduce that problem, the script can apply an impulse filter around the pivot that created the zone.
The impulse filter can evaluate factors such as:
- candle direction,
- candle range relative to ATR,
- candle body size relative to ATR,
- close location near the candle extreme,
- optional relative-volume participation.
The purpose of this filter is not to predict future direction by itself. Its purpose is simply to reduce zones that were formed without enough directional commitment.
5) QUALITY ENGINE
After a zone is created, the script can score it using an internal quality model.
The quality engine can consider:
- displacement after formation,
- reaction size after the first touch,
- penetration depth into the zone,
- repeated-touch penalty.
That information is then used to classify zones into internal grades such as:
- A,
- B,
- TRASH.
These grades are not guarantees and should not be interpreted as objective truth. They are simply the script’s own ranking method for separating stronger and weaker structural candidates under the current settings.
Users can keep all zones visible or restrict the workflow to higher-grade zones only.
6) FIRST-TOUCH REACTION MODEL
The central idea of the script is first-touch selection.
Rather than treating every revisit of a zone as equally important, the script attempts to detect the earliest qualifying return into a valid zone.
This makes the script more specific than:
- a basic supply and demand overlay,
- a general touch-alert tool,
- or a repeated-contact zone script.
For traders who consider early reactions to be structurally important, this framework may be useful because it intentionally avoids reacting in the same way to every later revisit of the same area.
7) TRADE PROJECTION LAYER
When a valid first-touch reaction is detected, the script can project a structured trade framework on the chart.
Depending on settings, this can include:
- BUY or SELL labels,
- an entry reference,
- stop loss,
- take profit,
- guide lines,
- TP and SL boxes,
- retained historical visual structure for later review.
This projection layer is not meant to claim that a setup will succeed. Its purpose is to reduce manual chart annotation and make the script’s reaction logic easier to inspect after the fact.
8) REVIEW PANELS
The script includes review panels that summarize projected historical behavior.
Depending on available chart history and current settings, the review may include metrics such as:
- total projected trades,
- wins,
- losses,
- win rate,
- profit factor,
- average result,
- net result,
- drawdown behavior,
- streak behavior.
A separate daily panel summarizes projected daily behavior according to the script’s configured timezone logic.
These panels are review tools only. They do not replace formal strategy testing, execution analysis, or live validation, and they should not be interpreted as promises of future performance.
WHAT MAKES THIS SCRIPT ORIGINAL
This script uses familiar technical-analysis building blocks such as pivots, ATR, candle structure, relative range expansion, optional volume comparison, and zone interaction logic.
Those building blocks are not original by themselves.
The originality of this script is not in inventing a completely new primitive indicator. The originality lies in how these familiar elements are arranged into one selective workflow:
pivot-based zone construction
→ optional multi-timeframe structure sourcing
→ impulse validation
→ quality scoring
→ first-touch selection
→ trade projection
→ on-chart review
That full sequence is the main reason this script exists as its own publication.
It is not intended to be simply another pivot tool, another ATR-based filter, or another chart dashboard. It is specifically a first-touch supply and demand reaction framework that combines structure detection, formation filtering, zone ranking, selective reaction logic, projection, and review in one workflow.
WHAT APPEARS ON THE CHART
Depending on settings, the chart may display:
- supply zones,
- demand zones,
- higher-timeframe zones,
- confirmed-zone coloring,
- zone labels,
- zone grades,
- BUY and SELL markers,
- entry / stop / target lines,
- TP / SL boxes,
- review panel,
- daily review panel.
Users who want a cleaner chart can disable some visual layers and keep only the ones most relevant to their workflow.
HOW TO USE THE SCRIPT
A practical workflow is:
1. Add the script to a standard candlestick chart.
2. Decide whether you want zones from the chart timeframe, from a higher timeframe, or from both.
3. Choose how strict touch detection should be by using wick touch, body touch, or both.
4. Enable the impulse filter if you want to reduce weaker pivot-based formations.
5. Enable the quality engine if you want to rank zones and restrict the workflow to stronger structural candidates.
6. Select the minimum accepted grade if you want stricter setup filtering.
7. Wait for a qualifying first-touch BUY or SELL reaction.
8. Use the projected entry, stop, and target structure as an analysis framework rather than as a blind instruction.
9. Review how prior projected setups behaved under the same settings.
10. Combine the script’s output with market context, execution rules, and risk management.
This script is best understood as a structured decision-support and chart-review tool, not as a fully self-sufficient trading system.
SETTINGS REFERENCE
Supply & Demand Engine
- Enable Supply & Demand Engine: turns structural zone detection on or off.
- Show S&D Zones: controls whether zone boxes are visible.
- Pip Value: converts pip-based calculations into instrument-specific price units.
- Pivot Left / Pivot Right: define pivot-confirmation depth.
- Use Chart Timeframe Zones: includes zones from the active chart timeframe.
- Use Higher Timeframe Zones: includes zones from the selected higher timeframe.
- Higher Timeframe: selects the HTF used for additional zone sourcing.
- Minimum Touches for Confirmed Zone: defines when a zone is considered confirmed.
- Zone Thickness (pips): controls zone thickness.
- Zone Merge Distance (pips): controls when nearby zones may be merged.
- Break Close Buffer (pips): defines the close-through buffer used in break logic.
- Maximum Stored Zones: limits how many zones remain in memory.
- Use Wick Touch / Use Body Touch: define how interaction with a zone is recognized.
Impulse Filter
- Enable Impulse Filter: turns pivot-strength filtering on or off.
- Impulse Candle Count: number of candles checked after pivot formation.
- ATR Length: ATR period used by the impulse model.
- Minimum Range x ATR: required range expansion relative to ATR.
- Minimum Body x ATR: required body expansion relative to ATR.
- Close Near Extreme: requires the candle to close near its extreme.
- Require Volume Condition: optionally adds a relative-volume filter.
- Volume SMA Length / Minimum Volume x SMA: control the volume filter.
Quality Engine
- Enable Quality Engine: turns zone scoring on or off.
- Displacement Bars: measures post-formation expansion.
- Minimum Displacement (pips): required structural push after formation.
- Reaction Window (bars): number of bars used to evaluate post-touch behavior.
- Minimum Reaction (pips): minimum bounce or rejection required.
- Maximum Penetration %: limits acceptable penetration into the zone.
- Touch Penalty: reduces score as repeated interaction accumulates.
- Hide TRASH Grade Zones: removes weaker zones from view.
- Show Grade on Zones: displays grade labels on the chart.
- Show Zone Labels / Zone Label Size: control zone-label visibility and size.
Trade Projection
- Enable Simulator: turns first-touch trade projection on or off.
- Take Profit RR: sets the target multiple relative to stop distance.
- Stop Loss (pips): sets the projected stop distance.
- Use Chart TF Signals Only: restricts projected setups to chart-timeframe zones.
- Minimum Grade: defines the lowest accepted grade for projected setups.
- Show Entry / Exit Labels: displays entry and exit labels.
- Show Entry / SL / TP Lines: displays projection lines.
- Projection Length (bars): extends projected visuals into future bars.
- Show TP / SL Boxes: displays TP and SL boxes.
- Box Fill / Border controls: change trade-box styling.
- Show Performance Panel / Panel Position: control review-panel visibility and position.
- Show Daily PnL Panel / Number of Days / Panel Position: control daily-review settings.
IMPORTANT PRACTICAL NOTE ON PIP VALUE
The script uses a Pip Value setting to convert internal pip-based distances into actual price distances.
This matters because different instruments use different decimal structures.
If zones, stop loss, take profit, or projected distances appear too compressed, too large, or otherwise inconsistent for the instrument being analyzed, the first setting to verify is Pip Value.
On some symbols, especially small-decimal forex instruments, this setting may need adjustment for the script’s structural and projection logic to behave as intended.
LIMITATIONS AND SHORTCOMINGS
This script has important limitations:
- It relies on pivot confirmation, so some structural elements are recognized only after a confirmation delay.
- Zone behavior can vary across symbols, brokers, spreads, sessions, and volatility regimes.
- Higher-timeframe zones depend on the selected timeframe and can materially change the number and spacing of setups.
- The quality engine is a ranking model, not an objective truth detector.
- The review panels reflect the script’s own projected logic and settings, not guaranteed tradable outcomes.
- The script can be sensitive to pip-conversion settings on some markets.
- First-touch logic is selective by design, so it may ignore later reactions that some traders would still consider relevant.
- No zone model can remove all false signals or all regime-dependent behavior.
For those reasons, the script should be used as a structured analysis and review framework, not as a promise of future profitability.
WHO THIS SCRIPT MAY BE USEFUL FOR
This script may be useful for traders who:
- study supply and demand behavior,
- care more about first-return reactions than repeated retests,
- want structural filtering rather than raw touch alerts,
- want automatic trade mapping for chart review,
- want historical on-chart review of projected outcomes.
It may be less suitable for traders who:
- want every zone retest marked,
- want a minimal chart with almost no overlays,
- want a finished strategy that requires no outside confirmation or discretion.
DISCLAIMER
This script is provided for educational and informational purposes only.
It does not constitute financial, investment, or trading advice.
Market conditions change, historical behavior does not guarantee future results, and users should perform their own analysis, validation, and risk management before using the script in live decision-making.
مؤشر Pine Script®






















