What it does

Anchored VWAP in this library uses a fixed bars-ago anchor and then carries the volume-weighted average forward from that point. It is a practical way to study how price behaves after a specific historical starting bar without turning the tool into a manual click-to-anchor workflow.

Who this is for

This page is aimed at traders who already know what problem Anchored VWAP is solving and want clearer notes on setup, tradeoffs, and platform coverage.

Key terms for this tool

Review the core trading and platform terms tied to this page before changing settings or using the study in a live workspace.

What it is not

Anchored VWAP is a chart-context tool. It does not place trades, manage risk automatically, or promise that a specific pattern will resolve in one direction. Use it to organize decisions, not to outsource them.

Chart examples

This chart capture shows the study on a real NinjaTrader workspace. Use it as visual reference, then confirm behavior on your own instrument, session, and timeframe.

Best fit

  • Framing price action from a fixed historical reference bar.
  • Comparing the session VWAP idea against a single anchored starting point.
  • Studying whether a move is holding above or below a bars-ago fair-value reference.

Before using it live

  • Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow, or start from the source block for another platform.
  • Use the anchor-bars-ago input as a fixed historical starting point rather than a rolling lookback.
  • Test the anchor behavior on a clean chart before adding it to a larger workspace.
  • Review how the tool behaves on your actual session template, chart type, and instrument.

Settings to review

Anchor bars ago

Sets the historical bar used as the fixed starting point for the anchored VWAP calculation.

VWAP color

Controls the color of the anchored VWAP plot on the chart.

Chart history

Changes how far back the fixed anchor can be placed before the study starts plotting.

Installation notes

  1. Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow, or start from the source block for another platform.
  2. Use the anchor-bars-ago input as a fixed historical starting point rather than a rolling lookback.
  3. Test the anchor behavior on a clean chart before adding it to a larger workspace.

Downloads

FreeIndicators Anchored VWAP for NinjaTrader 8 NinjaTrader 8
Download

After the download

Keep the next step tied to this exact tool

Install it cleanly, subscribe for future updates if this workflow matters, or move straight into a structured request if the tool needs another platform or a custom version.

Source code

These source examples are provided for copy/paste workflows on other charting platforms. Review and test any script in a simulator before using it on a live chart.

TradeStation EasyLanguage / MultiCharts PowerLanguage AnchoredVWAP.eld.txt
{
  Anchored VWAP
  FreeIndicators.com source example.
  Works as a starting point for TradeStation EasyLanguage and MultiCharts PowerLanguage.
}

Inputs: AnchorBarsAgo(30);
Vars: PV(0), V(0), AnchorBar(0), AVWAP(0), PriceValue(0);

AnchorBar = MaxList(1, MaxBarsBack - AnchorBarsAgo);

If CurrentBar < AnchorBar Then
  Plot1(0, "AnchoredVWAP")
Else Begin
  If CurrentBar = AnchorBar Then Begin
    PV = 0;
    V = 0;
  End;

  PriceValue = TypicalPrice;
  PV = PV + PriceValue * Volume;
  V = V + Volume;
  AVWAP = IFF(V > 0, PV / V, PriceValue);
  Plot1(AVWAP, "AnchoredVWAP");
End;
MetaTrader 4 MQL4 AnchoredVWAP.mq4
// Anchored VWAP
// FreeIndicators.com source example for MetaTrader 4.
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Crimson
#property indicator_color3 SeaGreen

double Buffer1[];
double Buffer2[];
double Buffer3[];

int init() {
   SetIndexBuffer(0, Buffer1);
   SetIndexBuffer(1, Buffer2);
   SetIndexBuffer(2, Buffer3);
   return(0);
}

int start() {
   int counted = IndicatorCounted();
   int limit = Bars - counted - 1;
   int anchorBarsAgo = 30;
   int anchorShift = MathMax(0, Bars - 1 - anchorBarsAgo);
   double pv = 0, v = 0;
   ArrayInitialize(Buffer1, EMPTY_VALUE);
   for(int shift = Bars - 1; shift >= 0; shift--) {
      if(shift > anchorShift) continue;
      double price = (High[shift] + Low[shift] + Close[shift]) / 3.0;
      pv += price * Volume[shift];
      v += Volume[shift];
      Buffer1[shift] = v > 0 ? pv / v : price;
   }
   return(0);
}
MetaTrader 5 MQL5 AnchoredVWAP.mq5
// Anchored VWAP
// FreeIndicators.com source example for MetaTrader 5.
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3

double Buffer1[];
double Buffer2[];
double Buffer3[];

int OnInit() {
   SetIndexBuffer(0, Buffer1, INDICATOR_DATA);
   SetIndexBuffer(1, Buffer2, INDICATOR_DATA);
   SetIndexBuffer(2, Buffer3, INDICATOR_DATA);
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[]) {
   int start = prev_calculated > 1 ? prev_calculated - 1 : 1;
   int anchorBarsAgo = 30;
   int anchorIndex = MathMax(0, rates_total - 1 - anchorBarsAgo);
   double pv = 0, v = 0;
   for(int i = 0; i < rates_total; i++) Buffer1[i] = EMPTY_VALUE;
   for(int i = anchorIndex; i < rates_total; i++) {
      double price = (high[i] + low[i] + close[i]) / 3.0;
      pv += price * tick_volume[i];
      v += tick_volume[i];
      Buffer1[i] = v > 0 ? pv / v : price;
   }
   return(rates_total);
}
TradingView Pine Script v5 AnchoredVWAP.pine
//@version=5
indicator("Anchored VWAP", overlay=true)

anchorBarsAgo = input.int(30, "Anchor bars ago", minval=1)
anchorBar = math.max(0, last_bar_index - anchorBarsAgo)
var float pv = 0.0
var float v = 0.0
var float anchoredVWAP = na

if bar_index < anchorBar
    anchoredVWAP := na
else
    if bar_index == anchorBar
        pv := 0.0
        v := 0.0
    pv += hlc3 * volume
    v += volume
    anchoredVWAP := v > 0 ? pv / v : hlc3

plot(anchoredVWAP, "Anchored VWAP", color=color.blue)

Limitations

  • The anchor is fixed by bars-ago count, not by a manual chart click.
  • Anchored VWAP is context, not a direct entry or exit signal.
  • Volume quality still matters, especially on decentralized feeds.

Frequently asked questions

Does it repaint?

This indicator is designed as a chart reference tool, not as a hindsight-only backfitted signal. Even so, you should still test it bar by bar on your chart type to confirm how it behaves on the active bar.

Which platforms are covered?

NinjaTrader 8, TradeStation EasyLanguage, MultiCharts PowerLanguage, MetaTrader 4, MetaTrader 5, TradingView Pine Script are currently represented through downloads or source pages.

Is source code included?

Yes. This page includes source examples or links to platform-specific source pages where applicable.