Jay
Jay

Reputation: 71

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

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

Upvotes: 1

Views: 2263

Answers (1)

Gerard
Gerard

Reputation: 1

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

Upvotes: 0

Related Questions