PulseHub
OPEN-SOURCE SCRIPT

Auto AVWAP - Consecutive Violations

97
Auto AVWAP with Consecutive Violation Control

This indicator plots automatically anchored Volume Weighted Average Price levels for potential support and resistance.

It maintains two primary Anchored VWAPs:

- High AVWAP: an upper reference derived from price highs or HLC3.
- Low AVWAP: a lower reference derived from price lows or HLC3.

It also calculates two developing “Next” AVWAPs. These represent potential future anchors identified through price extremes and Stochastic RSI conditions.

The main purpose of this version is to provide explicit control over when an active AVWAP is considered invalid. Unlike the original implementation, a main AVWAP is not replaced merely because a new price extreme appears or because the Stochastic RSI confirms a reversal. It remains active until price violates it for a configurable number of consecutive bars.

Core calculation

Each AVWAP is calculated as:

AVWAP = Sum(Price × Volume) / Sum(Volume)

By default, the indicator uses:

- High for the High AVWAP calculation.
- Low for the Low AVWAP calculation.

Users can disable the High/Low setting to calculate both AVWAPs from HLC3 instead.

Anchor candidate logic

Stochastic RSI and new price extremes are used to identify and maintain possible future anchor points.

The developing candidate levels are displayed as:

- High Next: potential future upper AVWAP.
- Low Next: potential future lower AVWAP.

These candidate levels can continue to develop without immediately replacing the active AVWAPs.

Consecutive violation control

A High AVWAP is considered violated when the selected price source is above it.

A Low AVWAP is considered violated when the selected price source is below it.

The active AVWAP is replaced only after the required number of consecutive violations has been reached. If a bar does not violate the level, the corresponding counter returns to zero.

This prevents a single wick, temporary breakout, or isolated close from prematurely replacing an established AVWAP.

Configurable violation source

The violation source can be selected from:

- Close: uses the candle close.
- Open: uses the candle open.
- High/Low: uses the high for High AVWAP violations and the low for Low AVWAP violations.

The “Count only closed bars” option prevents an unfinished real-time candle from temporarily increasing the violation counter.

Default configuration

The default configuration requires three consecutive confirmed closes:

- Consecutive bars to invalidate: 3
- Violation source: Close
- Count only closed bars: Enabled

This configuration is intended to filter isolated price excursions while allowing a sustained break to invalidate the active level.

Plots

The indicator displays:

- High AVWAP: primary upper reference.
- Low AVWAP: primary lower reference.
- High Next: developing upper candidate.
- Low Next: developing lower candidate.

The primary plots use stronger colors and greater width. Candidate plots use more transparent colors.

Alerts

The indicator includes alerts for:

- Breakout in either direction.
- High AVWAP resistance break.
- Low AVWAP support break.
- High AVWAP invalidation after consecutive violations.
- Low AVWAP invalidation after consecutive violations.

The breakout alerts can use either the candle open or close through the corresponding input.

How to use

- Treat the High AVWAP as a dynamic upper reference or potential resistance area.
- Treat the Low AVWAP as a dynamic lower reference or potential support area.
- Use the Next plots to monitor developing replacement anchors.
- Increase the required number of violations to retain AVWAPs for longer.
- Decrease it to make the indicator respond more quickly to sustained price breaks.
- Prefer confirmed closes when the objective is to reduce reactions to intrabar noise.
- Adjust the settings according to the symbol, timeframe, liquidity, and volatility regime.
- Combine the levels with market structure, volume analysis, and risk management.

Open-source reuse and credits

This script is based on the open-source indicator:

“Auto AVWAP (Anchored-VWAP)” by Electrified.

Original source:
Auto AVWAP (Anchored-VWAP)


This version adds and/or changes:

1) Consecutive-bar invalidation for the primary High and Low AVWAPs.
2) Configurable violation count.
3) Selectable Close, Open, or High/Low violation source.
4) Optional confirmed-bar-only counting.
5) Removal of automatic primary AVWAP replacement caused solely by new price extremes.
6) Removal of automatic primary AVWAP replacement caused solely by Stochastic RSI reversal confirmation.
7) Promotion of a developing candidate only after the active AVWAP satisfies its invalidation rule.
8) Dedicated High and Low AVWAP invalidation alerts.
9) Clear separation between candidate-anchor formation and active-level invalidation.

Limitations

- An AVWAP is a volume-weighted reference, not a guaranteed support or resistance level.
- Consecutive-bar confirmation introduces a deliberate delay before invalidation.
- Using High/Low as the violation source is more sensitive to intrabar price excursions.
- Candidate anchors depend on price extremes and Stochastic RSI behavior.
- Results vary across symbols, timeframes, sessions, and volatility regimes.
- Historical plots do not guarantee future market behavior.
- This is a decision-support tool, not a guaranteed-profit system.
- Risk management is required.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.