OPEN-SOURCE SCRIPT

VWAP Anclado a Fecha

90
//version=5
indicator("Anchored VWAP (Custom Date)", overlay=true)

// === INPUT ===
// Select any specific date and time to anchor the VWAP
anchorDate = input.time(timestamp("2024-01-01 00:00 +0000"), title="Anchor Date")

// === VARIABLES ===
var float cumPV = na // cumulative price * volume
var float cumVol = na // cumulative volume
var float anchoredVWAP = na

// === VWAP CALCULATION ===
if (time >= anchorDate)
cumPV := na(cumPV) ? hlc3 * volume : cumPV + hlc3 * volume
cumVol := na(cumVol) ? volume : cumVol + volume
anchoredVWAP := cumPV / cumVol

// === PLOT ===
plot(anchoredVWAP, title="Anchored VWAP", color=color.blue, linewidth=2)

// Optional marker to show anchor start
plotshape(time == anchorDate ? close : na, title="Anchor Start", location=location.belowbar, color=color.red, style=shape.triangleup, size=size.small)

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.