Amibroker AFL: How to plot Custom Anchored VWAP (AVWAP) passing any specific date to it

1.9k Views Asked by At

Below is the code for Anchored VWAP which will select Date based on my mouse click, my query is how to plot Anchored VWAP passing date as a parameter, so it will be constant across all symbols.

Eg: I want to pass "2021-03-26" as Date parameter so it will plot AVWAP starting from "2021-03-26" date.

_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();
1

There are 1 best solutions below

1
On

Change sd = SelectedValue( dn ); into sd = DateTimeConvert( 2, 1210326 );