All indicators

VWAP For Loop

Aug 19, 2025

Static chart image
Dynamic OverlaysVolume BasedSignalsOscillators

The VWAP For Loop indicator is a volume-weighted trend gauge that anchors VWAP to a specific calendar period and scores the persistence of that trend using a breadth-style calculation. It provides traders with a threshold-driven oscillator to identify sustained market regimes and institutional price trends.

Usage

The indicator can be used to identify trend strength and potential reversals by analyzing how consistently the current anchored VWAP stays above or below its historical values.

  • Trend Confirmation: When the oscillator score stays near its maximum positive value, it indicates entrenched strength. Traders can use these periods to seek long entries during pullbacks to the anchored VWAP.
  • Regime Detection: By setting specific thresholds (e.g., +40 for long and -10 for short), the script filters out noise and only signals a regime change when a broad consensus of lookback steps is reached.
  • Intraday vs. Swing Trading: Users can adjust the anchor period to suit their timeframe. For example, a "Day" anchor is suitable for intraday scalping, while "Month" or "Quarter" anchors are better for swing trading on 1h or 4h charts.

Details

The script operates on two primary components:

  1. Anchored VWAP: It calculates VWAP using the hlc3 price and resets at the start of every selected calendar period (Day, Week, Month, Quarter, or Year).
  2. For-Loop Scoring: The indicator runs a loop through a user-defined lag window. For each step, it compares the current VWAP to the VWAP $i$ bars ago. If current > past, it adds +1; otherwise, it subtracts -1.
  3. Stateful Logic: The "out" state variable creates "sticky" signals. A long regime is triggered when the score exceeds the upper threshold, while a short regime is triggered specifically on a crossunder of the lower threshold, helping to capture momentum shifts more effectively.

Settings

VWAP

  • VWAP Anchor Period: Selects the timeframe reset for the VWAP calculation (Day, Week, Month, Quarter, or Year).

Calculation Settings

  • Calculation Start: The starting lag index for the comparison loop.
  • Calculation End: The maximum lag index for the comparison (capped at 50 for performance).

Signals

  • Long Threshold: The score required to trigger a long regime (e.g., 40).
  • Short Threshold: The score level used for crossunder detection to trigger a short regime (e.g., -10).

UI Settings

  • Show Threshold Lines?: Toggles the visibility of horizontal threshold levels in the oscillator pane.
  • Color Bars According to Trend?: Enables candle coloring based on the current detected regime.
  • Background Colour: Toggles background shading for the current regime.
  • Signal Line Width: Adjusts the thickness of the oscillator line.
  • Show VWAP: Displays the anchored VWAP on the price chart via a forced overlay.
  • Color VWAP with Trend: Allows the VWAP line to change color dynamically based on the oscillator's state.

FAQ

How do I access VWAP For Loop?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Why are the default thresholds asymmetric?

The default thresholds (40 and -10) are designed to demand high persistence for an uptrend while remaining sensitive to downward momentum shifts. This helps capture strong rallies while flagging potential exits or reversals more quickly.

Does the script repaint?

The indicator uses standard historical data and does not look ahead. However, because it relies on an anchored VWAP that resets, the score calculation immediately following a period reset may incorporate data from the previous period until the lookback window is fully populated within the new period.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.