OPEN-SOURCE SCRIPT
ZenAlgo - ABC

This indicator identifies a three-point price structure (X, A, B) and projects proportional price levels forward from point B. It uses either automatically detected swing points or manually selected anchors and then builds a forward projection framework based on the relative movement between X and A.
1. Anchor Point Selection (X, A, B)
The script first determines three key price points that define the reference movement.
Automatic mode
When manual anchors are disabled, the indicator scans historical bars to detect local highs and lows using a fixed number of bars on the left and right side. A pivot high is confirmed only after enough future bars exist, and the same applies to pivot lows. This avoids using information that is not yet available in real time.
Detected pivots are stored in sequence:
To avoid repeatedly using the same type of pivot, the script alternates between highs and lows. This ensures that X, A, and B always represent a swing structure instead of a flat sequence.
Manual mode
When manual anchors are enabled, the user defines three timestamps. The script captures the price and bar index at those times. After all three points are collected, the script adjusts them to represent true extremes inside their bars. Depending on direction, it replaces closes with highs or lows so that X and A form a valid swing, and B represents a corrective endpoint.
If manual anchors are incomplete, the script falls back to the automatic pivots.
2. Validation and Direction Detection
After anchors are collected, the script checks whether all three points are available. If any of them is missing, no projection is drawn.
When X, A, and B exist, the script determines the directional context:
The vertical distance between X and A defines the reference movement. This distance is treated as the base unit for all further projections.
This approach assumes that the impulse move from X to A represents the dominant directional leg, and that B represents a retracement or pause within that structure.
3. Projection Calculation
All projected levels are derived from the difference between X and A and are applied starting from point B.
For each predefined ratio:
This produces a set of horizontal price levels that are proportional to the initial impulse.
No fixed price values are used. All levels scale automatically with market volatility and with the size of the X–A movement.
4. Configurable Levels and Naming
The indicator defines a list of projection ratios that represent retracement, extension, and continuation zones. Each level can be enabled or disabled and has an adjustable color and transparency.
Each level may be displayed in two ways:
The naming system maps specific ratios to semantic labels such as base, entry, intermediate targets, main target, and extended continuation levels. These names are fixed in the script and reflect their relative position in the projection structure.
5. Visual Construction
On the most recent bar, the script clears all previously drawn elements and rebuilds the full structure.
It then draws:
All level lines extend a configurable number of bars to the right of the current bar, creating a forward projection area.
Transparency values are fixed to maintain visual consistency and to avoid obscuring price action.
6. Zone Construction
In addition to individual lines, the script can draw shaded zones between selected pairs of levels.
These zones include:
Zones are drawn as semi-transparent rectangles from point B to the right extension limit. Their vertical boundaries are defined by the corresponding projected levels.
These zones highlight areas where price interaction with multiple proportional levels is expected.
7. Display and Update Logic
The drawing process runs only on the most recent bar. This prevents excessive historical objects and ensures that projections always reflect the latest confirmed X, A, and B.
All graphical objects are stored internally and deleted before redrawing. This avoids overlap and keeps the chart synchronized with the current structure.
8. Interpretation of Levels
The projected levels represent proportional price distances derived from the prior impulse.
They should be interpreted as:
Lower ratios correspond to shallow projections near B. Higher ratios correspond to extended moves away from B.
No level represents a guaranteed support or resistance. All values are conditional on the validity of the underlying X–A–B structure.
9. Practical Usage
Typical usage follows this workflow:
Manual anchors can be used when the user wants to enforce a specific structure that differs from the automatic pivot logic.
The indicator is designed for contextual analysis rather than standalone signal generation.
10. Limitations and Disclaimers
This indicator depends on confirmed pivots. In fast or highly volatile markets, pivot confirmation can lag, which delays projections.
Structures may be invalidated when:
In such conditions, projected levels may shift frequently or lose relevance.
The method assumes that past impulse size is a meaningful reference for future movement. This assumption does not hold in all market regimes.
The indicator does not incorporate volume, order flow, trend filters, or volatility regimes. It should therefore be combined with additional analysis.
11. Relationship to Manual Fibonacci and ABC Tools
Unlike standard manual Fibonacci retracement or projection tools, this indicator does not rely on subjective anchor placement. In automatic mode, swing points are selected using a fixed pivot detection process, which enforces consistent structural rules.
This removes the need for repeated manual adjustments when market structure changes.
Compared to typical ABC projection tools, the script formalizes the entire workflow. The selection of reference points, the construction of proportional levels, and the management of graphical objects are handled programmatically. This prevents inconsistent anchor choices, reduces user interpretation bias, and ensures that projections always reflect the most recent validated structure.
The integrated zone construction further extends standard projection methods by grouping related levels into continuous price regions, rather than displaying only isolated horizontal lines.
Summary
This script identifies swing-based X–A–B structures using confirmed pivots or manual anchors, measures the impulse between X and A, and projects proportional levels from B. All displayed lines and zones are derived from this single reference movement and update dynamically as new pivots appear. The indicator provides a structured projection framework based on historical price geometry rather than predictive signals.
1. Anchor Point Selection (X, A, B)
The script first determines three key price points that define the reference movement.
Automatic mode
When manual anchors are disabled, the indicator scans historical bars to detect local highs and lows using a fixed number of bars on the left and right side. A pivot high is confirmed only after enough future bars exist, and the same applies to pivot lows. This avoids using information that is not yet available in real time.
Detected pivots are stored in sequence:
- The previous confirmed pivot becomes X
- The next confirmed pivot becomes A
- The most recent confirmed pivot becomes B
To avoid repeatedly using the same type of pivot, the script alternates between highs and lows. This ensures that X, A, and B always represent a swing structure instead of a flat sequence.
Manual mode
When manual anchors are enabled, the user defines three timestamps. The script captures the price and bar index at those times. After all three points are collected, the script adjusts them to represent true extremes inside their bars. Depending on direction, it replaces closes with highs or lows so that X and A form a valid swing, and B represents a corrective endpoint.
If manual anchors are incomplete, the script falls back to the automatic pivots.
2. Validation and Direction Detection
After anchors are collected, the script checks whether all three points are available. If any of them is missing, no projection is drawn.
When X, A, and B exist, the script determines the directional context:
- If A is above X, the structure is treated as bullish
- If A is below X, the structure is treated as bearish
The vertical distance between X and A defines the reference movement. This distance is treated as the base unit for all further projections.
This approach assumes that the impulse move from X to A represents the dominant directional leg, and that B represents a retracement or pause within that structure.
3. Projection Calculation
All projected levels are derived from the difference between X and A and are applied starting from point B.
For each predefined ratio:
- In bullish structures, the distance from X to A is added upward from B
- In bearish structures, the distance is subtracted downward from B
This produces a set of horizontal price levels that are proportional to the initial impulse.
No fixed price values are used. All levels scale automatically with market volatility and with the size of the X–A movement.
4. Configurable Levels and Naming
The indicator defines a list of projection ratios that represent retracement, extension, and continuation zones. Each level can be enabled or disabled and has an adjustable color and transparency.
Each level may be displayed in two ways:
- As a descriptive name combined with the ratio
- As a numeric ratio combined with the projected price
The naming system maps specific ratios to semantic labels such as base, entry, intermediate targets, main target, and extended continuation levels. These names are fixed in the script and reflect their relative position in the projection structure.
5. Visual Construction
On the most recent bar, the script clears all previously drawn elements and rebuilds the full structure.
It then draws:
- A dashed line from X to A and from A to B to visualize the underlying swing
- Labels at X, A, and B with direction-aware placement
- Horizontal lines from B into the future for each enabled level
- Text labels at the end of each level line
All level lines extend a configurable number of bars to the right of the current bar, creating a forward projection area.
Transparency values are fixed to maintain visual consistency and to avoid obscuring price action.
6. Zone Construction
In addition to individual lines, the script can draw shaded zones between selected pairs of levels.
These zones include:
- A retracement zone between two closely spaced mid-range ratios
- A target zone between the main extension levels
- An extended continuation zone above or below the main target
Zones are drawn as semi-transparent rectangles from point B to the right extension limit. Their vertical boundaries are defined by the corresponding projected levels.
These zones highlight areas where price interaction with multiple proportional levels is expected.
7. Display and Update Logic
The drawing process runs only on the most recent bar. This prevents excessive historical objects and ensures that projections always reflect the latest confirmed X, A, and B.
All graphical objects are stored internally and deleted before redrawing. This avoids overlap and keeps the chart synchronized with the current structure.
8. Interpretation of Levels
The projected levels represent proportional price distances derived from the prior impulse.
They should be interpreted as:
- Reference zones for potential reactions
- Areas of interest for continuation or exhaustion
- Context for managing existing positions
Lower ratios correspond to shallow projections near B. Higher ratios correspond to extended moves away from B.
No level represents a guaranteed support or resistance. All values are conditional on the validity of the underlying X–A–B structure.
9. Practical Usage
Typical usage follows this workflow:
- Wait for the script to confirm X, A, and B
- Observe whether the structure is bullish or bearish
- Use projected levels as reference for planning entries, exits, and risk placement
- Re-evaluate when a new pivot replaces X, A, or B
Manual anchors can be used when the user wants to enforce a specific structure that differs from the automatic pivot logic.
The indicator is designed for contextual analysis rather than standalone signal generation.
10. Limitations and Disclaimers
This indicator depends on confirmed pivots. In fast or highly volatile markets, pivot confirmation can lag, which delays projections.
Structures may be invalidated when:
- Price forms new extremes before a pivot is confirmed
- Market conditions change abruptly
- Range-bound markets produce frequent small pivots
In such conditions, projected levels may shift frequently or lose relevance.
The method assumes that past impulse size is a meaningful reference for future movement. This assumption does not hold in all market regimes.
The indicator does not incorporate volume, order flow, trend filters, or volatility regimes. It should therefore be combined with additional analysis.
11. Relationship to Manual Fibonacci and ABC Tools
Unlike standard manual Fibonacci retracement or projection tools, this indicator does not rely on subjective anchor placement. In automatic mode, swing points are selected using a fixed pivot detection process, which enforces consistent structural rules.
- Anchor points are derived from confirmed price pivots instead of manual selection
- The X–A–B structure is maintained automatically as new swings form
- All projection levels and zones are recalculated and redrawn dynamically
This removes the need for repeated manual adjustments when market structure changes.
Compared to typical ABC projection tools, the script formalizes the entire workflow. The selection of reference points, the construction of proportional levels, and the management of graphical objects are handled programmatically. This prevents inconsistent anchor choices, reduces user interpretation bias, and ensures that projections always reflect the most recent validated structure.
The integrated zone construction further extends standard projection methods by grouping related levels into continuous price regions, rather than displaying only isolated horizontal lines.
Summary
This script identifies swing-based X–A–B structures using confirmed pivots or manual anchors, measures the impulse between X and A, and projects proportional levels from B. All displayed lines and zones are derived from this single reference movement and update dynamically as new pivots appear. The indicator provides a structured projection framework based on historical price geometry rather than predictive signals.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
The ZenAlgo team
zenalgo.com
discord.zenalgo.com
zenalgo.com
discord.zenalgo.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
The ZenAlgo team
zenalgo.com
discord.zenalgo.com
zenalgo.com
discord.zenalgo.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.