Below is the code for Anchored VWAP which will select Date based on my mouse click, my query is how to Calculate anchored Vwap since when the contract is born
For example: some option contract is born on 7 may 2023 and some other in 5 April 2023 I want to calculate anchored Vwap value since the day that option is born.
_SECTION_BEGIN("CustomAVWAP");
dn = DateTime();
sd = SelectedValue( dn );
start = dn == sd;
mp = C;
PV = mp * V;
CV = Cum( V );
VSS = CV - ValueWhen( start, CV );
denom = IIf( VSS == 0, 1, VSS );
num = Cum( PV ) - ValueWhen( start, Cum( PV ) );
M = IIf( BarsSince( start ), num/denom, mp );
Plot( C, Date() + " Close", colorBrightGreen, styleBar );
Plot( M, "PSVWAP", colorBrightGreen, styleThick );
_SECTION_END();
I don’t understand how to fetch the date of the option contract’s first candle.