OPEN-SOURCE SCRIPT
Atualizado

Trade Location Quality [AGPro Series]

942
Trade Location Quality [AGPro Series]

🧠 Core Idea

Is price in a clean trade location, or is it too close to obstruction, invalidation, or noisy range edges?


📌 Overview / What it does

Trade Location Quality [AGPro Series] is a chart-overlay risk-location planner designed to evaluate whether the current price area is practical for setup review.

The script measures range position, nearby obstruction rails, ATR-normalized risk distance, target room, trend support, and volatility fit. These inputs are combined into a 0-100 Location Quality Score with a clear state such as Clean Location, Watch Location, Obstructed, Danger Close, Risk Wide, or Poor Location.

It produces a forward location window, target/risk rails, compact event labels, alert conditions, and a premium AGPro panel. It does not predict price direction, automate execution, or print direct buy/sell commands.


🎯 Purpose & Design Philosophy

This script was built to solve a common planning problem: a setup may look interesting, but the trade location may still be weak because price is too stretched, too close to the next obstacle, or too close to invalidation.

The goal is to help traders think in terms of location quality before reacting to a setup. It supports a planning mindset: check context, evaluate room, review risk, then decide whether the area deserves attention.

It is designed for traders who want a clean decision layer rather than another generic signal marker.


⚡ Why This Script Is Different

Most tools focus on detecting a level, zone, breakout, or signal.

This script does NOT build a premium/discount map, OTE model, generic support/resistance scanner, order-block map, or prediction engine.

Instead, it asks a narrower planning question: is the current location clean enough to evaluate, or is the chart already blocked by risk, obstruction, or poor range position?


⚙️ Methodology

1. Context Detection
The script identifies the active evaluation side using either Auto Context, Long Context, or Short Context. Auto Context follows the trend-support basis.

2. Reference Mapping
It maps the recent range, nearest obstruction rails, opposite-side risk rail, estimated invalidation reference, and ATR-normalized room.

3. Reaction Evaluation
It scores location quality using range position, target room, risk distance, trend support, and volatility fit.

4. Visual Output
It displays a forward location window, target/risk rails, state labels, alerts, and a compact AGPro panel.


🗺️ How to Read the Chart

Location Window = the current area where price location is being evaluated.

Target Obstruction Rail = the nearest meaningful obstacle in the evaluation direction.

Risk Rail = the opposite-side reference used to estimate invalidation distance.

Labels = compact state markers showing the current planner condition and score.

Colors = teal and indigo suggest stronger quality, amber suggests caution, and pink/red suggests weak or risky location.

Panel = summarizes score, state, range position, obstruction distance, risk state, and next action.


🚦 Signals & States

• Clean Location → location score is strong, room is sufficient, and risk distance is balanced.

• Watch Location → context is acceptable but not strong enough for the clean-location state.

• Obstructed → price is too close to the next target-side obstruction rail.

• Danger Close → invalidation is too close for a balanced location read.

• Risk Wide → invalidation is too far away, making the location less efficient.

• Poor Location → score and context are not strong enough for planning attention.


🔔 Alerts Logic

• Clean Location → triggers when the script enters the Clean Location state.

• Obstructed Location → triggers when price becomes too close to the next obstruction rail.

• Risk Location Warning → triggers when risk distance becomes too tight or too wide.

• Watch Location → triggers when a watchable location context appears without reaching Clean Location.

Alerts are attention markers. They are not trade instructions.


🧩 Confluence Logic

Location quality improves when range position, target room, balanced risk distance, trend support, and stable volatility align.

The strongest read appears when the score is high and the panel also shows enough obstruction distance with a balanced risk state.


📊 When to Use

• During setup planning before reacting to a signal.

• Around pullbacks where risk and target room matter.

• During trend continuation review when price may be clean or already stretched.

• Before breakout or reversal evaluation when nearby obstruction can change the quality of the idea.

• On liquid markets where ATR and pivot references are meaningful.


⚠️ When NOT to Use

• Extremely low-liquidity markets with unreliable candles.

• Highly noisy periods where rails change too frequently.

• Extreme volatility spikes where ATR-based distance can expand rapidly.

• Charts where the user has no broader context for directional evaluation.

• As a standalone reason to enter or exit a trade.


🎛️ Key Inputs

• Evaluation Context → selects Auto, Long, or Short planning context.

• Location Lookback → defines the recent structure window.

• Obstruction Pivot Length → controls how strict obstruction rails are.

• Minimum Clean Score → sets the quality threshold for Clean Location.

• Minimum Target Room ATR → controls how much room must exist before the next obstruction.

• Risk Buffer Inputs → define what counts as too close or too wide.

• Visual Settings → control compact or detailed labels, rails, location window, panel visibility, theme, location, and font sizes.


🖥️ Interface & Visual Design

The interface is intentionally chart-first.

The location window shows the active evaluation area without filling the chart with many competing zones. The obstruction rails provide practical reference points. The default labels use compact state tags, while hover tooltips retain the deeper score, room, risk, and action context. Cooldown and maximum-visible settings keep the chart active but not crowded.

The panel follows the AGPro publication layout with a single merged blue title row, adjustable location, adjustable theme, and adjustable font size.


🧪 Practical Usage Workflow

1. Read the panel score and state.

2. Check whether target-side room is open or obstructed.

3. Review whether risk distance is balanced, too close, or too wide.

4. Compare the location window with broader market context.

5. Treat alerts and labels as attention markers, not decisions.


🔍 Interpretation Guidelines

A high score means the location is cleaner relative to the script's rule set. It does not mean price must move in the evaluated direction.

An obstructed state means room is limited before the next nearby reference. It does not mean price cannot break through that area.

A risk warning means the current location is less balanced for planning. It should be interpreted with timeframe, volatility, and broader structure.


🚫 What This Script Is NOT

• Not a prediction engine.

• Not financial advice.

• Not auto trading.

• Not guaranteed signals.

• Not a buy/sell signal service.

• Not a premium/discount or OTE zone engine.

• Not a generic support/resistance zone scanner.


⚠️ Limitations & Transparency

Location quality depends on the selected lookback, pivot length, volatility profile, and timeframe.

Different markets can produce different rail behavior. High volatility may widen risk distance. Low volatility may compress target room. Small timeframes may produce more frequent state changes.

The script is rule-based and should be read as a planning tool inside broader analysis.


🧠 Market Context Notes

Trade location is not only about where price is. It is also about what sits nearby.

A location can look attractive but still be weak if there is not enough clean room before the next obstruction. A location can also be risky if invalidation is too close or too far for the current volatility environment.

This script organizes those conditions into a single readable decision layer.


🧾 Use Case Examples

When price pulls back inside a trend and the score improves while risk remains balanced, the chart may deserve closer review.

When price is near a target-side rail and the panel shows Obstructed, the user can recognize that nearby room is limited.

When volatility expands and risk distance becomes too wide, the script can mark the location as less efficient for planning.


🧱 System Philosophy

Trade Location Quality follows the AGPro decision-engine approach: the script should help the user evaluate context, quality, risk, room, and next action without promising an outcome.

The goal is not to add another signal. The goal is to improve the quality of the planning process.


🔐 Non-Promise Statement

No script can guarantee direction, continuation, reversal, or outcome.

This tool provides structured chart context only.


📉 Risk Disclosure

Trading involves risk.

Users are responsible for their own analysis, risk controls, position sizing, and trading decisions.

This script does not provide financial advice, investment advice, or guaranteed trading outcomes.


📚 Educational Note

Use the script to study how trade location changes as price moves closer to risk, target, obstruction, and range edges. The most useful reading comes from comparing the panel state with the visible chart context.
Notas de Lançamento
UPDATE NOTES - V1.2

This update focuses on visual hierarchy, chart readability, label balance, and publication-ready interpretation.

The core purpose of the script remains unchanged.
Trade Location Quality continues to evaluate whether price is positioned in a clean execution area or too close to obstruction, invalidation, noisy range edges, or wide-risk structure.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

- Added Engine Presets
Balanced Location, Cleaner Swing, Active Intraday, and Custom presets were added so users can quickly adapt the planner to swing, intraday, or manual tuning workflows.

- Refined the Location Window
The active location window now has a stronger centered TLQ score and state label, giving the chart a clearer focal point without turning the script into a signal spam tool.

- Improved Obstruction Rail Presentation
Upper and lower rails were refined with optional compact rail labels so the user can understand target obstruction and risk-side structure faster.

- Rebalanced Event Labels
Default label text now uses compact state tags, label cooldown was adjusted, and visible label retention was increased slightly to keep the chart active without creating stacked labels.

- Updated Panel Structure
The panel now follows the AGPro standard more closely with a single merged blue title row, clearer row hierarchy, location score, state, range position, obstruction, risk state, action, and best-view guidance.

- Added Alert Controls
Clean and watch alerts can be controlled separately from obstruction and risk-warning alerts.


------------------------
Visual Improvements
------------------------

- Improved chart readability by making the active location window the main visual reference.

- Reduced unnecessary visual clutter while keeping enough event labels for a premium public chart.

- Refined visual hierarchy so the TLQ score, state, obstruction rails, and risk context are easier to read at first glance.

- Adjusted label positioning so event labels stay above or below candles instead of being buried inside price bars.

- Added a centered label inside the location window to make the zone self-explanatory.


------------------------
Interface & Usability
------------------------

- Optimized panel layout for clearer information flow.

- Improved label readability through compact default label text and adjustable font size.

- Added an Engine Preset input to reduce setup friction for new users.

- Added optional rail labels for users who want clearer obstruction context.

- Preserved adjustable panel visibility, panel location, panel theme, label font size, and panel font size.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical purpose of the script.

The scoring model still combines range position, obstruction room, risk distance, trend support, and volatility fit into a 0-100 location quality score.

The goal is to improve clarity and usability, not to introduce predictive behavior.

Users should interpret outputs the same way as before, but with a cleaner visual structure and better chart organization.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe differences, and fast structural changes may affect how location states appear.

Obstruction rails are derived from recent structure and should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Notas de Lançamento
UPDATE NOTES - VERSION 1.3

This update focuses on readability, visual structure, panel flow, and chart interpretation.

The core purpose of the script remains unchanged.
This release improves how the existing location-quality logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

- Reworked the location workflow language.
State names now use action-oriented review wording such as Review Location, Track Reaction, Check Room, Build Buffer, Risk Too Wide, and Stand Aside.

- Improved the AG Pro panel structure.
The panel now follows a clearer dashboard flow: Workflow, Location Context, Quality Score, Room / Range, Risk Distance, and ATR Context.

- Expanded panel controls.
Panel visibility, location, theme, and font-size controls are now complete, including center-location options and dark / light publication themes.

- Refined the active location window.
The location window now uses a stronger centered premium badge instead of relying on weak embedded box text.

- Improved label and rail readability.
Event labels are shorter, easier to scan, and positioned with ATR-based spacing so they are less likely to disappear inside candles.


------------------------
Visual Improvements
------------------------

- Improved chart readability by adjusting labels, rail tags, zone badge placement, and default spacing.

- Reduced visual clutter while keeping the chart active enough for public screenshots.

- Refined visual hierarchy so the current location window, score, room, and risk context stand out more clearly.

- Adjusted label positioning to reduce overlap with candles and nearby price action.


------------------------
Interface & Usability
------------------------

- Optimized panel layout for clearer first-glance interpretation.

- Added a stronger workflow row so users can quickly understand the current review state.

- Improved label readability for better chart interaction.

- Adjusted default visual settings for a more balanced publication-ready appearance.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

The goal is to improve clarity and usability, not to introduce new predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe selection, and structure quality may affect how labels, rails, and location windows appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Notas de Lançamento
🔧 UPDATE NOTES - V1.4

This update focuses on publication polish, rail clarity, panel stability, and first-glance chart readability.

The core purpose of the script remains unchanged.
This release improves how the existing trade-location logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Improved rail-label anchoring
Rail labels can now be offset to the right while their dotted reference rails extend to the same x-position, so the labels remain visibly attached to real levels.

• Cleaned location-window rendering
The location window now relies on the separate centered premium badge instead of empty box text handling, keeping the visual layer cleaner and more robust.

• Refined AG Pro panel refresh behavior
The panel now resets when font size changes and keeps the blue title row as a single merged header without repeatedly rebuilding the header structure.

• Updated short title
The short title now follows the AGPro publication style more closely while keeping the main title unchanged.

• Preserved the full feature set
No scoring logic, rail logic, alerts, labels, panel rows, presets, or visual controls were removed.


------------------------
Visual Improvements
------------------------

• Improved chart readability by making room/risk labels visually connected to their rails

• Reduced ambiguity around whether right-side rail labels point to empty chart space

• Refined visual hierarchy so the location window, centered badge, rails, labels, and panel read as one coherent planning layer

• Kept event labels active enough for a premium public chart while preserving controlled density


------------------------
Interface & Usability
------------------------

• Added a Rail Label Offset Bars control for cleaner right-edge spacing

• Optimized panel behavior for font-size changes and stable header rendering

• Preserved adjustable panel visibility, location, theme, panel font size, and label font size

• Improved public screenshot quality without changing how users interpret the model


------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

The goal is to improve clarity and usability, not to introduce new predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure and cleaner reference labeling.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe differences, and fast structural changes may affect how location states appear.

Obstruction rails are derived from recent structure and should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Notas de Lançamento
🔧 UPDATE NOTES - v1.5

This update focuses on decision confidence and proof.

The core purpose of the script remains unchanged.
This release adds a confirmation-anchored proof layer that measures how often the
reviewed location advanced one risk unit in favor before invalidation on the symbol.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Added a Proof Layer (Follow / Hold / React / Flip)
The panel now reports how reliably the active review context advanced from the reviewed
location on the current symbol and timeframe. Rolling evaluation windows in the review
direction are tracked forward over a configurable horizon, with the follow target set to one
risk unit (1R) in favor, or the nearer room edge if it is closer, and the invalidation
reference frozen at the start of each window:
- Follow Rate : share of windows that advanced one risk unit in favor (or reached a nearer
room edge) before the invalidation reference was breached
- Hold Rate : share whose invalidation reference was not breached through resolution
- React Rate : share that produced an early favorable push
- Flip Rate : share whose invalidation reference was breached within the horizon
A sample size (n) is shown so the rates are read in context, and they display as
"building" only during the brief warmup before the first window resolves.

• Added rate outputs to the hidden data plots
The Follow / Hold / React / Flip rates join the existing location score, target room, and
risk distance outputs as hidden plots so they can be referenced by alerts, screeners, or
other tools without changing the chart visuals.


------------------------
Visual Improvements
------------------------

• Grouped the proof metrics into a clean block under a dedicated "Proof @ Confirm" heading,
below the existing location rows.

• Preserved the existing location window, centered window badge, obstruction rails, rail
labels, and event labels.

• Refined panel structure so the workflow, location context, quality, room, risk, and proof
context form a single, scannable decision card.

• Kept the window badge centered in its zone and all event labels offset away from candles
for clean readability.


------------------------
Interface & Usability
------------------------

• Optimized panel layout for clearer information flow with the new proof block.

• Improved at-a-glance interpretation by reporting how often the reviewed location advanced
favorably before invalidation.

• Adjusted default visual settings for a more balanced appearance.

• Added a Proof input group (show/hide, proof horizon bars, reaction window bars, reaction
progress threshold) so the proof layer is fully configurable without affecting the core
location logic.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

The proof rates are descriptive statistics of rolling location windows on the current symbol
and timeframe. They measure how often price advanced one risk unit in favor (or reached a
nearer room edge) before the invalidation reference, not trade performance, and they do not
change how the location score or workflow state is classified.

Users should interpret outputs the same way as before, now with added reliability context.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Proof rates depend on the amount of available history and on the current symbol and
timeframe; a small sample (low n) should be treated with caution. Each rolling window is
counted once, with the follow target set to one risk unit in favor (or a nearer room edge)
and the invalidation reference frozen at the start of the window. Market conditions such as
volatility, liquidity, and timeframe differences may affect how locations and rates appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Notas de Lançamento
Version 1.6.1 — Professional Label Hierarchy and Visual Density Refinement

This update refines event-label priority, cluster handling, price-side placement, and historical label density while preserving the Version 1.6 analytical engine, scoring model, obstacle memory, alerts, panel structure, and confirmation-anchored Proof layer.

• Rebuilt the visual event-label workflow around broader constructive and warning families.

• Review and Watch transitions are treated as constructive events, while Buffer, Wide Risk, and Room obstruction conditions are grouped into a unified warning family.

• Removed separate labels for every rapid raw-state fluctuation inside the same warning sequence.

• Nearby events inside one compact bar cluster now update the most recent label instead of creating another overlapping chart object.

• The latest meaningful state replaces the prior cluster text, color, position, tooltip, and score presentation.

• Constructive and warning labels now use opposite sides of price, creating a clearer visual distinction between favorable review context and location-risk warnings.

• Added three alternating ATR-based vertical label lanes for separate historical event clusters.

• Reduced the likelihood of labels occupying the same candle and price coordinates during rapid state changes.

• Restricted periodic context labels to Review and Watch states.

• Increased periodic-label spacing to five effective cooldown periods.

• Reduced default retained-label density for Balanced Location, Cleaner Swing, and Active Intraday profiles.

• Preserved the raw Max Visible Labels setting when Custom mode is selected.

• Preserved all existing location scoring, risk-distance logic, target-room analysis, obstacle rails, Proof calculations, panel rows, alerts, hidden exports, and AGPro visual styling.

No analytical signal or score behavior was changed in this patch.

Existing TradingView alerts do not need to be recreated solely for the visual label changes in Version 1.6.1. Recreate them only if you also want the full Version 1.6 analytical updates applied to older alerts.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.