1

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();
Jay
  • 71
  • 6

1 Answers1

0

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

Gerard
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 22 '23 at 20:08