anchoredVWAP
Syntax (one line)
Parameters
Return Value
Example
//@version=1
init = () => {
indicator({ onMainPanel: true, format: 'inherit' });
};
onTick = () => {
// Draw occasionally to avoid clutter
if (index % 40 === 0) {
// 1) Choose an anchor bar (meaningful pivot/event)
const anchor = newPoint(time(80), closeC(80));
// 2) Full style following AnchoredvwapLineToolOverrides
const style = {
// Background under the VWAP/bands
areaBackground: {
backgroundColor: color.rgba(255, 165, 0, 0.12),
fillBackground: true,
transparency: 85
},
// Optional per-zone background (example using Background_1)
filledAreasStyle: {
Background_1: {
color: color.rgba(255, 165, 0, 0.18),
transparency: 82,
visible: true
}
},
// Label/number precision
precision: 'auto',
// Band calculations and source
inputs: {
'Bands Calculation Mode': 'Standard', // or 'Percent'
bands_multiplier: 1.0, // ยฑ1.0 band
bands_multiplier_2: 0, // disable others by setting 0 + calculate false
bands_multiplier_3: 0,
calculate_stDev: true,
calculate_stDev_2: false,
calculate_stDev_3: false,
source: 'hlc3', // typical VWAP source
start_time: undefined // derived from anchor; no need to set manually
},
// Line styles for VWAP and bands
styles: {
VWAP: { color: color.orange, linestyle: 2, linewidth: 2, plottype: 0, trackPrice: true, transparency: 0 },
UpperBand: { color: color.yellow, linestyle: 0, linewidth: 1, plottype: 0, trackPrice: false, transparency: 10 },
LowerBand: { color: color.yellow, linestyle: 0, linewidth: 1, plottype: 0, trackPrice: false, transparency: 10 },
// Disabled bands (kept for clarity)
UpperBand_2:{ color: color.gray, linestyle: 1, linewidth: 1, plottype: 0, trackPrice: false, transparency: 80 },
LowerBand_2:{ color: color.gray, linestyle: 1, linewidth: 1, plottype: 0, trackPrice: false, transparency: 80 },
UpperBand_3:{ color: color.gray, linestyle: 1, linewidth: 1, plottype: 0, trackPrice: false, transparency: 80 },
LowerBand_3:{ color: color.gray, linestyle: 1, linewidth: 1, plottype: 0, trackPrice: false, transparency: 80 }
}
};
// 3) Build anchored VWAP with deviation bands
anchoredVWAP(anchor, style);
}
};Tips
Warning
Good Practice
Last updated