Auto Midas Anchored VWAP

Category: Indicators By: Iván González Created: February 6, 2026, 7:35 PM
February 6, 2026, 7:35 PM
Indicators
0 Comments

The Auto Midas Anchored VWAP (developed by xdecow) is an advanced volume-weighted tool that automates the concept of Anchored VWAP (AVWAP) based on the MIDAS (Market Interpretation/Data Analysis System) approach. Unlike standard VWAPs that reset daily, this indicator automatically anchors its calculations to significant swing highs and lows across four different time horizons.

 

How It Works

 

ProRealTime’s ProBuilder engine evaluates data starting from the oldest bar to the most recent. This indicator identifies the highest and lowest points within specific lookback periods and “anchors” a volume-weighted average price calculation to those points.

 

The indicator operates on four hierarchical levels:

 

  • Level 1 (Short-term): 17 bars.
  • Level 2 (Intermediate): 72 bars.
  • Level 3 (Long-term): 305 bars.
  • Level 4 (Macro): 1292 bars.

 

For each level, it calculates a Top VWAP (anchored to the highest high) and a Bottom VWAP (anchored to the lowest low). This creates dynamic “clouds” of support and resistance that react to both price and volume intensity.

 

Technical Optimization Note

 

As a ProBuilder program, this code is evaluated at the end of each bar. Because the indicator uses FOR loops to calculate volume-weighted averages over long periods (up to 1292 bars), it is more computationally demanding than simple indicators. If you notice platform slowdowns, you can reduce the length of the macro levels.

 

Visual Interpretation

 

The indicator uses dynamic coloring and transparency (alpha) to highlight active zones:

 

  • Red Zones (Top AVWAP): Acts as a dynamic ceiling (resistance).
  • Green Zones (Bottom AVWAP): Acts as a dynamic floor (support).
  • Dynamic Alpha: The lines and fills change opacity based on whether the price is currently interacting with the level, making the most relevant zones immediately identifiable.

 

Indicator Settings

 

mdShow0 (Off)1 = Always show all levels; 0 = Only show levels currently active or interacting with price.

ma1Len17 Lookback period for the short-term anchor.

ma2Len72 Lookback period for the intermediate anchor.

ma3Len305 Lookback period for the long-term anchor.

ma4Len1292 Lookback period for the macro anchor.

 

You can modify these variables directly from the “Settings” interface without touching the code by adding them to the Variables menu.

 

Practical Applications

 

  • Trend Confirmation: When the price stays above the macro green clouds, the long-term trend is considered strongly bullish.
  • Mean Reversion: Look for price exhaustion when it overextends far from the short-term (Level 1) red or green bands.
  • Pullback Entry: The Level 2 and Level 3 AVWAPs often act as “value zones” where institutions re-enter a trend.

ProRealTime Code

 

// ---------------------------------------------------------
//PRC_Auto Midas Anchored VWAP (xdecow)
//version = 0
//06.02.2026
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
// ---------------------------------------------------------
// === PARAMETROS ===
// ---------------------------------------------------------
mdShow = 0 // 1=mostrar siempre, 0=solo cuando activo
ma1Len = 17
ma2Len = 72
ma3Len = 305
ma4Len = 1292
// === PRE-CALCULO ===
myHLC3 = (high + low + close) / 3
// =============================================
// NIVEL 1 (17 barras)
// =============================================
hb1 = HighestBars[ma1Len]
lb1 = LowestBars[ma1Len]

// Top VWAP anclado al maximo
IF hb1 = 0 THEN
   t1h = high
   t1m = myHLC3
ELSIF hb1 > 0 THEN
   sv = 0
   sw = 0
   sh = 0
   FOR i = 0 TO hb1 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sh = sh + volume[i] * high[i]
   NEXT
   IF sv > 0 THEN
      t1m = sw / sv
      t1h = sh / sv
   ELSE
      t1h = undefined
      t1m = undefined
   ENDIF
ELSE
   t1h = undefined
   t1m = undefined
ENDIF

// Bottom VWAP anclado al minimo
IF lb1 = 0 THEN
   b1l = low
   b1m = myHLC3
ELSIF lb1 > 0 THEN
   sv = 0
   sw = 0
   sl = 0
   FOR i = 0 TO lb1 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sl = sl + volume[i] * low[i]
   NEXT
   IF sv > 0 THEN
      b1m = sw / sv
      b1l = sl / sv
   ELSE
      b1l = undefined
      b1m = undefined
   ENDIF
ELSE
   b1l = undefined
   b1m = undefined
ENDIF

// Alpha Nivel 1
IF t1h <> undefined AND t1h > low THEN
   a1th = 255
   r1t = 255
   g1t = 0
   z1t = 0
ELSIF mdShow AND t1h <> undefined THEN
   a1th = 255
   r1t = 146
   g1t = 105
   z1t = 102
ELSE
   a1th = 0
   r1t = 0
   g1t = 0
   z1t = 0
ENDIF

IF b1l <> undefined AND b1l < high THEN
   a1bl = 255
   r1b = 0
   g1b = 128
   z1b = 0
ELSIF mdShow AND b1l <> undefined THEN
   a1bl = 255
   r1b = 82
   g1b = 117
   z1b = 82
ELSE
   a1bl = 0
   r1b = 0
   g1b = 0
   z1b = 0
ENDIF

IF a1th > 0 THEN
   a1tf = 30
ELSE
   a1tf = 0
ENDIF
IF a1bl > 0 THEN
   a1bf = 30
ELSE
   a1bf = 0
ENDIF
// =============================================
// NIVEL 2 (72 barras)
// =============================================
hb2 = HighestBars[ma2Len]
lb2 = LowestBars[ma2Len]

IF hb2 = 0 THEN
   t2h = high
   t2m = myHLC3
ELSIF hb2 > 0 THEN
   sv = 0
   sw = 0
   sh = 0
   FOR i = 0 TO hb2 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sh = sh + volume[i] * high[i]
   NEXT
   IF sv > 0 THEN
      t2m = sw / sv
      t2h = sh / sv
   ELSE
      t2h = undefined
      t2m = undefined
   ENDIF
ELSE
   t2h = undefined
   t2m = undefined
ENDIF

IF lb2 = 0 THEN
   b2l = low
   b2m = myHLC3
ELSIF lb2 > 0 THEN
   sv = 0
   sw = 0
   sl = 0
   FOR i = 0 TO lb2 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sl = sl + volume[i] * low[i]
   NEXT
   IF sv > 0 THEN
      b2m = sw / sv
      b2l = sl / sv
   ELSE
      b2l = undefined
      b2m = undefined
   ENDIF
ELSE
   b2l = undefined
   b2m = undefined
ENDIF

IF t2h <> undefined AND (t1h = undefined OR t1h < t2h) AND t2h > low THEN
   a2th = 255
   r2t = 255
   g2t = 0
   z2t = 0
ELSIF mdShow AND t2h <> undefined THEN
   a2th = 255
   r2t = 146
   g2t = 105
   z2t = 102
ELSE
   a2th = 0
   r2t = 0
   g2t = 0
   z2t = 0
ENDIF

IF b2l <> undefined AND (b1l = undefined OR b1l > b2l) AND b2l < high THEN
   a2bl = 255
   r2b = 0
   g2b = 128
   z2b = 0
ELSIF mdShow AND b2l <> undefined THEN
   a2bl = 255
   r2b = 82
   g2b = 117
   z2b = 82
ELSE
   a2bl = 0
   r2b = 0
   g2b = 0
   z2b = 0
ENDIF

IF a2th > 0 THEN
   a2tf = 40
ELSE
   a2tf = 0
ENDIF
IF a2bl > 0 THEN
   a2bf = 40
ELSE
   a2bf = 0
ENDIF
// =============================================
// NIVEL 3 (305 barras)
// =============================================
hb3 = HighestBars[ma3Len]
lb3 = LowestBars[ma3Len]

IF hb3 = 0 THEN
   t3h = high
   t3m = myHLC3
ELSIF hb3 > 0 THEN
   sv = 0
   sw = 0
   sh = 0
   FOR i = 0 TO hb3 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sh = sh + volume[i] * high[i]
   NEXT
   IF sv > 0 THEN
      t3m = sw / sv
      t3h = sh / sv
   ELSE
      t3h = undefined
      t3m = undefined
   ENDIF
ELSE
   t3h = undefined
   t3m = undefined
ENDIF

IF lb3 = 0 THEN
   b3l = low
   b3m = myHLC3
ELSIF lb3 > 0 THEN
   sv = 0
   sw = 0
   sl = 0
   FOR i = 0 TO lb3 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sl = sl + volume[i] * low[i]
   NEXT
   IF sv > 0 THEN
      b3m = sw / sv
      b3l = sl / sv
   ELSE
      b3l = undefined
      b3m = undefined
   ENDIF
ELSE
   b3l = undefined
   b3m = undefined
ENDIF

IF t3h <> undefined AND (t2h = undefined OR t2h < t3h) AND t3h > low THEN
   a3th = 255
   r3t = 255
   g3t = 0
   z3t = 0
ELSIF mdShow AND t3h <> undefined THEN
   a3th = 255
   r3t = 146
   g3t = 105
   z3t = 102
ELSE
   a3th = 0
   r3t = 0
   g3t = 0
   z3t = 0
ENDIF

IF b3l <> undefined AND (b2l = undefined OR b2l > b3l) AND b3l < high THEN
   a3bl = 255
   r3b = 0
   g3b = 128
   z3b = 0
ELSIF mdShow AND b3l <> undefined THEN
   a3bl = 255
   r3b = 82
   g3b = 117
   z3b = 82
ELSE
   a3bl = 0
   r3b = 0
   g3b = 0
   z3b = 0
ENDIF

IF a3th > 0 THEN
   a3tf = 50
ELSE
   a3tf = 0
ENDIF
IF a3bl > 0 THEN
   a3bf = 50
ELSE
   a3bf = 0
ENDIF
// =============================================
// NIVEL 4 (1292 barras)
// =============================================
hb4 = HighestBars[ma4Len]
lb4 = LowestBars[ma4Len]

IF hb4 = 0 THEN
   t4h = high
   t4m = myHLC3
ELSIF hb4 > 0 THEN
   sv = 0
   sw = 0
   sh = 0
   FOR i = 0 TO hb4 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sh = sh + volume[i] * high[i]
   NEXT
   IF sv > 0 THEN
      t4m = sw / sv
      t4h = sh / sv
   ELSE
      t4h = undefined
      t4m = undefined
   ENDIF
ELSE
   t4h = undefined
   t4m = undefined
ENDIF

IF lb4 = 0 THEN
   b4l = low
   b4m = myHLC3
ELSIF lb4 > 0 THEN
   sv = 0
   sw = 0
   sl = 0
   FOR i = 0 TO lb4 - 1 DO
      sv = sv + volume[i]
      sw = sw + volume[i] * myHLC3[i]
      sl = sl + volume[i] * low[i]
   NEXT
   IF sv > 0 THEN
      b4m = sw / sv
      b4l = sl / sv
   ELSE
      b4l = undefined
      b4m = undefined
   ENDIF
ELSE
   b4l = undefined
   b4m = undefined
ENDIF

IF t4h <> undefined AND (t3h = undefined OR t3h < t4h) AND t4h > low THEN
   a4th = 255
   r4t = 255
   g4t = 0
   z4t = 0
ELSIF mdShow AND t4h <> undefined THEN
   a4th = 255
   r4t = 146
   g4t = 105
   z4t = 102
ELSE
   a4th = 0
   r4t = 0
   g4t = 0
   z4t = 0
ENDIF

IF b4l <> undefined AND (b3l = undefined OR b3l > b4l) AND b4l < high THEN
   a4bl = 255
   r4b = 0
   g4b = 128
   z4b = 0
ELSIF mdShow AND b4l <> undefined THEN
   a4bl = 255
   r4b = 82
   g4b = 117
   z4b = 82
ELSE
   a4bl = 0
   r4b = 0
   g4b = 0
   z4b = 0
ENDIF

IF a4th > 0 THEN
   a4tf = 60
ELSE
   a4tf = 0
ENDIF
IF a4bl > 0 THEN
   a4bf = 60
ELSE
   a4bf = 0
ENDIF

// =============================================
// RELLENOS con alpha dinamico
// =============================================
colorbetween(t1h, t1m, 255, 0, 0, a1tf)
colorbetween(b1l, b1m, 0, 128, 0, a1bf)
colorbetween(t2h, t2m, 255, 0, 0, a2tf)
colorbetween(b2l, b2m, 0, 128, 0, a2bf)
colorbetween(t3h, t3m, 255, 0, 0, a3tf)
colorbetween(b3l, b3m, 0, 128, 0, a3bf)
colorbetween(t4h, t4m, 255, 0, 0, a4tf)
colorbetween(b4l, b4m, 0, 128, 0, a4bf)
// ---------------------------------------------------------
RETURN t1h coloured(r1t,g1t,z1t,a1th) style(line,1) AS "#1 ResH", b1l coloured(r1b,g1b,z1b,a1bl) style(line,1) AS "#1 SupL", t2h coloured(r2t,g2t,z2t,a2th) style(line,2) AS "#2 ResH", b2l coloured(r2b,g2b,z2b,a2bl) style(line,2) AS "#2 SupL", t3h coloured(r3t,g3t,z3t,a3th) style(line,3) AS "#3 ResH", b3l coloured(r3b,g3b,z3b,a3bl) style(line,3) AS "#3 SupL", t4h coloured(r4t,g4t,z4t,a4th) style(line,5) AS "#4 ResH", b4l coloured(r4b,g4b,z4b,a4bl) style(line,5) AS "#4 SupL"

Download
Filename: PRC_Auto-Midas-Anchored-VWAP.itf
Downloads: 96
Iván González Master
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

Logo Logo
Loading...