Price Action perspective using VWAP+SD and TF AMAs

pratapvb

Well-Known Member
#1
The idea of this thread is to discuss the Price Action perspective looking mainly at TF AMAs (Adaptive Moving Averages) and VWAP+SD (volume weighted average price and their Standard Deviation)

this will give what the bias is in the market like strong bull, mild bull, bull bias, neutral, bear bias, mild bear, strong bear

based on this one could decide how to enter, how much risk to take and whether to aggressively (for scalping if doing in mild to neutral market) or conservatively (for trend)

to keep this thread complete intend to post initially a summary of VWAP+SD and AMA perspective that I had put in the earlier thread
 

pratapvb

Well-Known Member
#2
Day's vwap with SD lines

here the SD lines start afresh at the beginning of day. So we need to give it some time like say to half an hour + like say to 9.45-10 atleast to use this for bias

some of the terms are borrowed from Market profile
so using the previous day vwap as POC (point of control) and previous day -1SD to +1SD (at close) as the Value Area. VAH Value area high and VAL value are low. Basically what we are saying is that approximately 70% of the trading previous day happened in thsi area, so if today also trading in this area then there is no new information that is pushing the market in any one direction.

Above VAH there is long bias and below VAL there is short bias

then today's price action that is today's Vwap+SD says what the market is doing with the new information. Above +1SD there is a strong up trend and below -1SD there is a strong down trend. If above VAH then between -1SD and +1SD there is a bull bias and if below VAL then between -1SD and +1SD there is a bear bias

 

pratapvb

Well-Known Member
#3
what about the broader perspective

I found that if we take a 2day rolling vwap and SD then we get that view. i.e. if today at 12 noon then all price bars from 2days back 12 noon to now are factored in the calculation of 2dayvwap and its SD

This gives when it is short term bull trend (above +1SD2) and bear trend (below -1SD2). Also it gives when it narrows the range through sideways like bollinger band.



 

pratapvb

Well-Known Member
#4
It is also observed that it rarely goes above +2SD2 or below -2SD2 unless there is some major news. Even then it usually pullsback after some time and then it then gets into that 1SD2 to 2SD2 range

 

pratapvb

Well-Known Member
#5
after a narrowing of range when it breaks out it is more likely to remain above/below +/-2SD2 for some longer time but then the SD lines catch up and they fall back within. something like overbought oversould and back

 
Last edited:

pratapvb

Well-Known Member
#6
a further higher perspective and corresponding s/rs can be derived by looking at 5dayvwap and its SDs. In this case I have also shown half SD lines

showing on 15min chart to show more days

 

pratapvb

Well-Known Member
#7
Price AFL

this also shows a high volume bar with a dot, scales the chart so that there is some white space above / below the current price

It can also be used to show a different higher TF in a different pane or even a different script of same or diff TF

Code:
_SECTION_BEGIN("HighVol");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;

useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
//List = GetCategorySymbols(categoryMarket, 0) ;
//forscript = ParamList("Scrip", List, 0) ;
forscript = ParamStr("Foreign Script", "BANKNIFTY-I") ;
if (useforeign)
	SetForeign(forscript); 

settf = ParamToggle("Set TF", "No|Yes", 0) ;
tf = Param("TF", 5, 1, 100000, 1) ;

if (settf)
{
	SetChartOptions(3,chartShowDates);
	TimeFrameSet(tf*in1Minute) ;
}

Layer = Param("Layer", 0, -5, 5, 1) ;
if (settf)
	tz = NumToStr(tf, 8.0) +"-minute";
else
	tz = NumToStr(Interval()/in1Minute, 8.0) +"-minute";

strname =  Name();
if (useforeign)
	strname = forscript ;

//_N(Title = StrFormat(Name() + " " +tz + " " + NumToStr(ddt, formatDateTime) + " Range %g {{VALUES}}", SelectedValue( dh-dl) ));
_N(Title = StrFormat(strname+tz+ NumToStr(DateTime(), formatDateTime)+ EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g,  " + EncodeColor( colorRed ) + " Lo %g,  " + EncodeColor( colorBlack ) + " Close %g (%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

showprice = ParamToggle("Show Price", "No|Yes", 1) ;
styleprice = IIf(showprice, 0, styleNoDraw) ;
//if (showprice)
	Plot( C, "Close",  colorBlack, styleNoTitle | styleCandle|styleprice,0,0,0,Layer ); 
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;

if (settf)
{
Daych = Day() != Ref(Day(), -1) ;
Plot(IIf(Daych, 100, 0), "", colorBlack, styleHistogram|styleNoLabel|styleOwnScale, 0, 100, 0, -5) ;
}
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False); 
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
//TimeFrameRestore()

Clronclose = ParamToggle("Color on yday close", "No|Yes", 0) ;
if (Clronclose)
{
	ydayc = TimeFrameGetPrice("C", inDaily,0, expandLast) ;

	Clr = IIf(C > ydayc, colorBlue, IIf(C < ydayc, colorRed, colorGrey40)) ;
	SetBarFillColor(Clr) ;
	Plot(C, "", Clr, styleCandle|styleNoLabel, 0, 0, 0, 1) ;
}

scalefromclose = ParamToggle("Scale from Close", "No|Yes", 1) ;
per = Param("Percentage",40,0,50,10);
Mingap = Param("Min Gap", 20, 1, 10000, 1) ;

if (scalefromclose)
{
	Lvh = Lvl = SelectedValue(C);
	Lvhh = HighestVisibleValue(H) ;
	Lvll = LowestVisibleValue(L) ;
	spl = sph = (Lvhh-Lvll)*per/100 ; // Param("pointsup",50,0,500,10);
	Plot( Max(Max(Lvh+sph, Lvhh+sph/2), Lvh+Mingap), "", colorBlack,styleNoDraw);
	Plot( Min(Min(Lvl-spl, Lvll-spl/2), Lvl-Mingap), "", colorBlack,styleNoDraw);
}


_SECTION_END();
 

pratapvb

Well-Known Member
#8
Day's Vwap

Code:
SetChartOptions(2,chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock ("price" x "number of 
      shares traded") and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is 
      calculated by Volume weighting all transactions during this time period

*/
Layer = Param("Layer", 0, -5, 5, 1) ;
showprice = ParamToggle("Show Price", "No|Yes", 0) ;
if (showprice)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g,  " + EncodeColor( colorRed ) + " Lo %g,  " + EncodeColor( colorBlack ) + " Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close",  colorBlack, styleNoTitle | styleCandle,0,0,0,Layer ); 
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False); 
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;
}

farback = Param("Far Back", 500, 1, 10000, 1) ;
SetChartBkColor(colorLightGrey) ;
useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
//List = GetCategorySymbols(categoryMarket, 0) ;
//forscript = ParamList("Scrip", List, 0) ;
forscript = ParamStr("Scrip", "NIFTY_F1") ;
if (useforeign)
	SetForeign(forscript); 

ndays = Param("N Days", 1, 0, 10000, 1) ;
period = Param("Period", 39, 1, 10000, 1) ;
turnvwapoff = ParamToggle("VWAP All OFF", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
nodraw = ParamToggle("No Draw", "No|Yes", 0) ;
showtradearr = ParamToggle("Trade Arrow", "No|Yes", 0) ;
Filterdaych = ParamToggle("Filter Day Change Connections", "No|Yes", 1) ;

Vwapmode = ParamList("VWAP mode", "As Per Param|Only VWAP|VWAP+SD|VWAP+2SD", 0) ;
showvwap = ParamToggle("Show VWAP", "No|Yes", 1) ;
showvwap1sd = ParamToggle("Show VWAP 1SD", "No|Yes", 1) ;
showvwap2sd = ParamToggle("Show VWAP 2SD", "No|Yes", 1) ;
showvwap3sd = ParamToggle("Show VWAP 3SD", "No|Yes", 0) ;
showvwapband = ParamToggle("Show VWAP Trend Bands", "No|Yes", 0) ;
showvwapswband = ParamToggle("Show VWAP Sideways Bands", "No|Yes", 0) ;
showprevdayvals = ParamToggle("Show Prev Day Values", "No|Yes", 1) ;
showprev2dayvals = ParamToggle("Show Prev 2 Day Values", "No|Yes", 1) ;
showprevdayband = ParamToggle("Show Prev Day Bands", "No|Yes", 1) ;
showextprevday = ParamToggle("Show Extension", "No|Yes", 1)  ;
showextbandprevday = ParamToggle("Show Extension Band", "No|Yes", 1)  ;
extend = Param("Extend", 10, 0, 100, 1) ;

showextvwap = ParamToggle("Show VWAP Extension", "No|Yes", 1)  ;
vwapextend = Param("VWAP Extend", 10, 0, 100, 1) ;
showexttrndband = ParamToggle("Show Trend Band Extension", "No|Yes", 0)  ;
trndbandextend = Param("Trend Band Extend", 5, 0, 100, 1) ;
showextswband = ParamToggle("Show Sidewways Band Extension", "No|Yes", 1)  ;
swbandextend = Param("Sideways Band Extend", 5, 0, 100, 1) ;

Vwaplayer = Param("VWAP Layer", -3, -5, 5, 1) ;
extlayer = Param("Extend Layer", -2, -5, 5, 1) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
SDwidthper = Param("SD Width %", 0.01, 0, 10, 1) ;
SDwidth = SelectedValue(C) * SDwidthper /100 ;
SD2widthper = Param("SD2 Width %", 0.005, 0, 10, 1) ;
SD2width = SelectedValue(C) * SD2widthper /100 ;

showcomm = ParamToggle("Show Commentary", "No|Yes", 0) ;
showtext = ParamToggle("Show Text", "No|Yes", 1) ;
Clrtext = ParamColor("Color Text", colorBlack) ;
showvahvaltext = ParamToggle("Show VAH-VAL Text", "No|Yes", 1) ;
showtxtlbl = ParamToggle("Show Text Label", "No|Yes", 1) ;

Onlyvwap = False ;
withsd = False ;
with2sd = False ;

switch (Vwapmode)
{
//	case "As Per Param":
//		break ;
	case "Only VWAP" :
		Onlyvwap = True ;
		break ;
	case "VWAP+SD" :
		Onlyvwap = True ;
		withsd = True;
		break ;
	case "VWAP+2SD" :
		Onlyvwap = True ;
		withsd = True;
		with2sd = True;
		break ;
}

if (Onlyvwap)
{	
	if (withsd)
		showvwap1sd = True;
	else
		showvwap1sd = False ;
	if (with2sd)
		showvwap2sd = True;
	else
		showvwap2sd = False ;
	showvwap3sd = False ;
	showvwapband = False ;
//	showvwapswband = False ;
//	showprevdayvals = False ;
//	showprev2dayvals = False ;
//	showprevdayband = False ;

//	showtradearr = False ;
	showcomm = False ;
	showtextlbl = showtext = withsd ;

}

stylelabel = 0 ;
if (showtext)
	stylelabel = styleNoLabel ;

styletitle = 0 ;
if (NOT showintitle)
	styletitle = styleNoTitle ;

styledata = 0 ;
if (nodraw)
{
	styledata = styleNoDraw ;
//showtradearr = False ;
}
//SetBarsRequired(int(farback*1.1)) ;

if (NOT turnvwapoff)
{
P = (H + L + C) / 3;
nd = Day() != Ref(Day(),-1) ;
Bars_so_far_today = 1 + BarsSince( nd);
if (ndays == 0)
	Bars_so_far_today = IIf(Bars_so_far_today < period, Bars_so_far_today, period) ;
else if (ndays > 1)
{
	bi = BarIndex() ;
/*
	bivwap0 = ValueWhen(nd, bi, ndays) ;
	bivwap1 = ValueWhen(nd, bi, ndays+1) ;

	dttn = DateTime() ;
	tnhr = DateTimeConvert(5, dttn) ;
	
	bivwap = IIf(tnhr < 12, bivwap1, bivwap0) ;
	Bars_so_far_today	 = 1 + (bi - bivwap) ;
*/
	bivwap = ValueWhen(nd, bi, ndays) ;
	nbar = (bi - bivwap) ;

	Bars_so_far_today	 = ValueWhen(nd, nbar, 1) *ndays ;
//	Bars_so_far_today	 = 375*ndays ;

}
Va = IIf(V == 0, 0.01, V) ;

//StartBar = ValueWhen(TimeNum() == 091600, BarIndex());
TodayVolume = Sum(Va,Bars_so_far_today);
//IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today  ) / TodayVolume,0);
//Plot (VWAP,"VWAP",colorBlack, styleThick);

	CumV = Sum(Va,Bars_so_far_today);
	CumVWP = Sum (P * Va, Bars_so_far_today  );
   VWAP = CumVWP / CumV;
//	S = Sum(Ref(CumV, 0) * V * (P - Ref(VWAP, 0))^2,Bars_so_far_today) / CumV;
	VWAPsd = IIf(Ref(nd, 1), 0, VWAP);
	CumVsd = IIf(Ref(nd, 1), 0, CumV);

	S = Sum(Ref(CumVsd, -1) * V * (P - Ref(VWAPsd, -1))^2 / CumV,Bars_so_far_today);
	Variance = S / CumV;
	 SD = sqrt(Variance);
//	 VWAP = IIf(InRange,  VWAP, Null);
	Vwapm1 = VWAP - SD ;
	Vwapp1 = VWAP + SD ;
	Vwapm2 = VWAP -2*SD ;
	Vwapp2 = VWAP +2*SD ;
	Vwapm3 = VWAP -3*SD ;
	Vwapp3 = VWAP +3*SD ;

	showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
	Refo = ParamField("CRB Open", 7+0) ;
	Refh = ParamField("CRB High", 7+1) ;
	Refl = ParamField("CRB Low", 7+2) ;
	Refc = ParamField("CRB Close", 7+3) ;
	Refbi = ParamField("CRB BI", 7+4) ;
	Refcrbbars = ParamField("CRB Bars", 7+5) ;
	Refnbars = ParamField("TF Bars", 7+6) ;
	Refdt = ParamField("CRB DT", 7+7) ;

	if (showoncrb)
		dt = Refdt ;
	else
		dt = DateTime() ;

	dtnum = DateTimeConvert(0, dt) ;
	newdt = dtnum != Ref(dtnum, -1) ;

	Lastbar = H-H ;
	if (Filterdaych)
		Lastbar = dtnum != Ref(dtnum, 1) ;

	if (showoncrb)
	{
		diffbars = Refnbars -Refcrbbars -1 ;
		Crbst = BarCount - LastValue(Refcrbbars) -1;
		// convert to crb
		RefVWAP = Ref(VWAP, -diffbars) ;
		RefVwapm1 = Ref(Vwapm1, -diffbars) ;
		RefVwapp1 = Ref(Vwapp1, -diffbars) ;
		RefVwapm2 = Ref(Vwapm2, -diffbars) ;
		RefVwapp2 = Ref(Vwapp2, -diffbars) ;
		RefVwapm3 = Ref(Vwapm3, -diffbars) ;
		RefVwapp3 = Ref(Vwapp3, -diffbars) ;

		k = 0 ;
		for ( i = Crbst ; i < BarCount ; i++)
		{
			Refbar = Refbi[i];

			RefVWAP[i] = VWAP[Refbar] ;
			RefVwapm1[i] = Vwapm1[Refbar] ;
			RefVwapp1[i] = Vwapp1[Refbar] ;
			RefVwapm2[i] = Vwapm2[Refbar] ;
			RefVwapp2[i] = Vwapp2[Refbar] ;
			RefVwapm3[i] = Vwapm3[Refbar] ;
			RefVwapp3[i] = Vwapp3[Refbar] ;

			k++;
		}
	}
	else
	{
			RefVWAP = VWAP;
			RefVwapm1 = Vwapm1;
			RefVwapp1 = Vwapp1 ;
			RefVwapm2 = Vwapm2;
			RefVwapp2 = Vwapp2;
			RefVwapm3 = Vwapm3;
			RefVwapp3 = Vwapp3;
	}

	Clrvwap =  ParamColor("Color VWAP",colorBlack) ;
	Clrvwapm1 = ParamColor("Color VWAP -1SD", colorGreen) ;
	Clrvwapp1 = ParamColor("Color VWAP +1SD", colorRed) ;

	strnday = NumToStr(ndays, 1.0)+"day";

		styleshow = IIf(showvwap, 0, styleNoDraw) ;
//		Vwapstyle = 0 ;

//		if (ndays > 1)
			Vwapstyle = styleNoRescale ;
		Plot(IIf(Lastbar, Null, RefVWAP), "VWAP"+strnday, Clrvwap , styleThick|stylelabel|Vwapstyle|styledata|styleshow, Null, Null, 0, 1);
		if (MAwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 1 ) ;

	Plot(SD, "SD", colorBlack, styleNoDraw|styleNoLabel|styleNoRescale) ;

		styleshow = IIf(showvwap1sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm1), "-1SD"+strnday, Clrvwapm1,  styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp1), "+1SD"+strnday, Clrvwapp1, styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;


		styleshow = IIf(showvwap2sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm2), "-2SD"+strnday, ParamColor("Color VWAP -2SD", colorSeaGreen), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp2), "+2SD"+strnday, ParamColor("Color VWAP +2SD", colorOrange), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), "",ParamColor("Color VWAP -2SD", colorSeaGreen), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), "",ParamColor("Color VWAP +2SD", colorOrange), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;


		styleshow = IIf(showvwap3sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm3), "-3SD"+strnday, ParamColor("Color VWAP -3SD", colorRed), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp3), "+3SD"+strnday, ParamColor("Color VWAP +3SD", colorBlue), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);

		styleshow = IIf(showvwapband, 0, styleNoDraw) ;	
		dnclr = ParamColor("Down Trend", colorRose) ;
		upclr = ParamColor("Up Trend", colorSkyblue) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm2), IIf(Lastbar, Null, RefVwapm2), "",dnclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp2), IIf(Lastbar, Null, RefVwapp2), "",upclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		if (showexttrndband)
		{
			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			x0 = BarCount - (trndbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp2) ;
			Ldlast = SelectedValue(RefVwapp1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", upclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;

			Hdlast = SelectedValue(RefVwapm1) ;
			Ldlast = SelectedValue(RefVwapm2) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;

			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", dnclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;
		}

		styleshow = IIf(showextvwap, 0, styleNoDraw) ;
		x0 = BarCount - (vwapextend+1)+1 ;
		x1 = BarCount -1 ;

		vwaplast = SelectedValue(RefVWAP) ;
		p1last = SelectedValue(RefVwapp1) ;
		m1last = SelectedValue(RefVwapm1) ;
		p2last = SelectedValue(RefVwapp2) ;
		m2last = SelectedValue(RefVwapm2) ;
showlvls = True ;

		vwapextPlot = LineArray(x0, vwaplast , x1, vwaplast ) ;
		Plot(vwapextPlot , "", Clrvwap, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (MAwidth > 0)
			PlotOHLC(vwapextPlot +MAwidth, vwapextPlot +MAwidth, vwapextPlot -MAwidth, vwapextPlot -MAwidth, "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;

		str = Null ;
		if(showtxtlbl)
			str = " vwap"  ;
		PlotText(NumToStr(Vwaplast, 8.1)+str, BarCount+Vwapextend-3, Vwaplast, colorBlack) ;

		p1extPlot = LineArray(x0, p1last , x1, p1last ) ;
		Plot(p1extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(p1extPlot +SDwidth , p1extPlot +SDwidth , p1extPlot -SDwidth , p1extPlot -SDwidth , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +1SD"  ;
		PlotText(NumToStr(p1last , 8.1)+str, BarCount+Vwapextend-3, p1last , colorBlack) ;

		m1extPlot = LineArray(x0, m1last , x1, m1last ) ;
		Plot(m1extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(m1extPlot +SDwidth , m1extPlot +SDwidth , m1extPlot -SDwidth , m1extPlot -SDwidth , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD"  ;
		PlotText(NumToStr(m1last , 8.1)+str, BarCount+Vwapextend-3, m1last , colorBlack) ;

		p2extPlot = LineArray(x0, p2last , x1, p2last ) ;
		Plot(p2extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(p2extPlot +SD2width , p2extPlot +SD2width , p2extPlot -SD2width , p2extPlot -SD2width , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD"  ;
		PlotText(NumToStr(p2last , 8.1)+str, BarCount+Vwapextend-3, p2last , colorBlack) ;

		m2extPlot = LineArray(x0, m2last , x1, m2last ) ;
		Plot(m2extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(m2extPlot +SD2width , m2extPlot +SD2width , m2extPlot -SD2width , m2extPlot -SD2width , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD"  ;
		PlotText(NumToStr(m2last , 8.1)+str, BarCount+Vwapextend-3, m2last, colorBlack) ;


		if (showoncrb)
		{
			Ht = Refh ;
			Lt = Refl ;
			Ct = Refc ;
		}
		else
		{
			Ht = H ;
			Lt = L ;
			Ct = C ;
		}

		Avgp = (Ht+Lt+Ct)/3 ;

	if (showtradearr)
	{

		Buy = Avgp >= Refvwapp1 ;
		Short = Avgp <= Refvwapm1 ;

		Sell =  Avgp <= Refvwapp1 ;
		Cover = Avgp >= Refvwapm1 ;

		Buy = ExRem(Buy, Short OR Sell) ;
		Short = ExRem(Short, Buy OR Cover) ;

		sdp1touch = False ; // Ht >= Refvwapp1 ;
		sdm1touch = False ; //Lt >= Refvwapm1 ;

		Sell = ExRem(Sell, Buy OR sdp1touch ) ;
		Cover = ExRem(Cover, Short OR sdm1touch ) ;

		PlotShapes(Cover*shapeUpArrow, colorBlack, 0, Ht, 12) ;
		PlotShapes(Sell*shapeDownArrow, colorBlack, 0, Lt, 12) ;

		PlotShapes(Buy*shapeUpArrow, colorBlue, 0, Ht, 12) ;
		PlotShapes(Short*shapeDownArrow, colorRed, 0, Lt, 12) ;

	}

	shift = Param("Shift", 0, -1, 0, 1) ;

	prevdayvalue = prevdayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 1) ;
	prevdayvaluelow = prevdayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 1) ;
	prevdayvaluehigh = prevdayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 1) ;
	prevdayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 1) ;


		styleshow = IIf(showvwapswband, 0, styleNoDraw) ;
		swclr = ParamColor("Sideways Color", colorLavender) ;
		upclr =  ParamColor("Bull Bias Color", colorSkyblue) ;
		dnclr =  ParamColor("Bear Bias Color", colorRose) ;

		if (ndays >= 1)
		{

			bandclr = IIf(Refvwap < prevdayvaluelow, dnclr, IIf(Refvwap > prevdayvaluehigh, upclr, swclr)) ;

			
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow|styleshow, 0, 0, 0, Vwaplayer ) ;
			
		if (showextswband)
		{
			styleshow = IIf(showextprevday, 0, styleNoDraw) ;
			x0 = BarCount - (swbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp1) ;
			Ldlast = SelectedValue(RefVwapm1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextswband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", bandclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,swbandextend ,extlayer ) ;

		}


		}
		else
				PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), "",swclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;


		if (shift == -1)
		{
			prevdayvaluehigh = prevdayvwap;
			prevdayvalue = prevdayvwapm1 ;
			prevdayvaluelow = prevdayvwapm2 ;
		}

		styleshow = IIf(showprevdayvals, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, prevdayvalue), "Prev VWAP", Clrvwap, styleDots|styleNoRescale+stylelabel|styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluelow), "VAL"+strnday, Clrvwapm1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluehigh), "VAH"+strnday, Clrvwapp1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;

		Clrprevdayband = ParamColor("Prev Day Band Color", colorLightYellow);

			styleshow = IIf(showprevdayband, 0, styleNoDraw) ;
			PlotOHLC(IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluehigh), IIf(Lastbar, Null, prevdayvaluehigh), "",Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;

			styleshow = IIf(showprev2dayvals, 0, styleNoDraw) ;
			prev2dayvalue = prev2dayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 2) ;
			prev2dayvaluelow = prev2dayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 2) ;
			prev2dayvaluehigh = prev2dayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 2) ;
			prev2dayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 2) ;

			Plot(IIf(Lastbar, Null, prev2dayvalue), "2day prev VWAP"+strnday, Clrvwap, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluelow), "2day VAL"+strnday, Clrvwapm1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluehigh), "2day VAH"+strnday, Clrvwapp1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;

		styleshow = IIf(showextprevday, 0, styleNoDraw) ;
		x0 = BarCount - (extend+1)+1 ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(prevdayvaluehigh ) ;
		Ldlast = SelectedValue(prevdayvaluelow ) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextbandprevday, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrprevdayband, styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend,extlayer ) ;


	showvwaptrend = ParamToggle("Show VWAP Trend", "No|Yes", 0) ;
	barht = Param("Bar Ht", 3, 1, 100) ;
	showvwaptrendtradearr =  ParamToggle("Show VWap Trend Arr", "No|Yes", 0) ;
	showallhalf =  ParamToggle("Show All half Triggers", "No|Yes", 1) ;

	fil = Param("Filter", 1, 1, 100, 1) ;

	showvwaptrendtriggers =  ParamToggle("Show Vwap Trend Triggers", "No|Yes", 1) ;
	showfiltered = ParamToggle("Show Filtered Text", "No|Yes", 1) ;
	trigfil = Param("Trigger Filter", 2.2, 0, 100) ;

	txtoff = Param("Text Off", 10, 0, 1000) ;

		styleshow = IIf(showvwaptrend, 0, styleNoDraw) ;
//		up = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 >= Ref(RefVwapm1, -1);
//		down = RefVwapp1 <= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1) ;
//		expand = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1);
//		Clr = IIf(up AND down, colorLavender, IIf(up, colorBlue, IIf(down, colorRed, IIf(expand, IIf(Ct > RefVwap, colorGreen, colorLightOrange), colorLavender)))) ;
//		Plot(4, "", Clr, styleArea|styleNoLabel|styleOwnScale|styledata|styleshow, 0, 100,-1) ;

rc = IIf(showoncrb, Refc, C) ;

		up = rc > (RefVwapp1+fil) ;
		down = rc < (RefVwapm1-fil) ;

		upbias = rc > (prevdayvaluehigh+fil) ;
		dnbias = rc < (prevdayvaluelow-fil) ;
		Clr = IIf(up, colorBlue, IIf(down, colorRed, 
					IIf(upbias, colorSkyblue, 
						IIf(dnbias, colorLightOrange, colorLavender)))) ;

		Plot(barht, "", Clr, styleArea|styleNoLabel|styleOwnScale|styleshow, 0, 100,0) ;

if (showvwaptrendtradearr)
{
Clrup = colorBlue ;
Clrdn = colorRed ;
Clrupbias = colorSkyblue ;
Clrdnbias = colorLightOrange ;
Clrsw = colorLavender ;

	Buyall = Shortall = Buyhalf = Shorthalf = Coverall = Sellall = H-H ;

		Buy = Clr == Clrup OR Clr == Clrupbias ;
		Short = Clr == Clrdn OR Clr == Clrdnbias ;
		Sell = (Clr != Clrup) ;
		Cover  = (Clr != Clrdn) ;
	if (showallhalf)
	{
		Buyhalf = Clr == Clrupbias AND Ref(Clr, -1) != Clrup AND H < (RefVwapp1-fil);
		Shorthalf = Clr == Clrdnbias AND Ref(Clr, -1) != Clrdn AND L > (RefVwapm1+fil);
	}
	else
	{
		Buyhalf = Clr == Clrupbias AND Ref(Clr, -1) != Clrup AND 
				((L < RefVwap AND C > Refvwap) OR (H > RefVwapp1 AND C < Refvwapp1) );
		Shorthalf = Clr == Clrdnbias AND Ref(Clr, -1) != Clrdn AND 
				((H> RefVwap AND C < Refvwap) OR (L < RefVwapm1 AND C < Refvwapm1) );
	}

	Buyfull = Clr == Clrup ;
	Shortfull = Clr == Clrdn ;

	Buyhalf = ExRem(Buyhalf , Short OR Sell) ;
	Shorthalf = ExRem(Shorthalf , Buy OR Cover) ;

	Buyfull = ExRem(Buyfull , Short OR Sell) ;
	Shortfull = ExRem(Shortfull , Buy OR Cover) ;

shpfull = Param("Trigger Shape", 1, 1, 100) ;
ibar = Param("Trigger Display Bar", 0, -10, 10)  ;
Clrup = colorBlue;
Clrdown = colorRed ;
Clrsoh = colorBlack ;


	Sell = ExRem(Sell, Buyfull ) ;
	Cover = ExRem(Cover, Shortfull) ;
	PlotShapes((Cover AND NOT Buyhalf AND NOT Buyfull)*shpfull, ClrSOH, 0, H, 12) ;
	PlotShapes((Sell AND NOT Shorthalf AND NOT Shortfull)*(shpfull+1), ClrSOH, 0, L, 12) ;

	PlotShapes((Buyhalf AND NOT Buyfull)*(shpfull+2), ClrUp, 0, H, 12) ;
	PlotShapes((Shorthalf AND NOT Shortfull)*(shpfull+2+1), ClrDown, 0, L, 12) ;
	PlotShapes(Buyfull*shpfull, ClrUp, 0, H, 8) ;
	PlotShapes(Shortfull*(shpfull+1), ClrDown, 0, L, 8) ;

if(showvwaptrendtriggers)
{
bi = BarIndex() ;

st = LowestVisibleValue(bi) ;
ed = HighestVisibleValue(bi) ;


	for (i = st; i <=ed ; i++)
	{
		Htrig = H ;
		Ltrig = L ;
		if (showfiltered)
		{
			Htrig = ceil(H[i])+trigfil ;
			Ltrig = floor(L[i])-trigfil ;
		}

		if (Cover[i])
			PlotText(NumToStr(Htrig, 8.2), i-ibar, H[i] +txtoff-2, colorBlack) ;
		if (Sell[i])
			PlotText(NumToStr(Ltrig, 8.2), i-ibar, L[i] -txtoff-2, colorBlack) ;

		if (Buyhalf[i])
			PlotText(NumToStr(Htrig, 8.2), i-ibar, H[i] +txtoff-2, colorBlue) ;
		if (Shorthalf[i])
			PlotText(NumToStr(Ltrig, 8.2), i-ibar, L[i] -txtoff-2, colorRed) ;

		if (Buyfull[i])
			PlotText(NumToStr(Htrig, 8.2), i-ibar, H[i] +txtoff-2, colorBlue) ;
		if (Shortfull[i])
			PlotText(NumToStr(Ltrig, 8.2), i-ibar, L[i] -txtoff-2, colorRed) ;
	}
}	

}
	if (showcomm AND NOT nodraw)
	{
		tdayvalue = RefVWAP ;
		tdayvaluehigh = Refvwapp1 ;
		tdayvaluelow = Refvwapm1 ;

		prevdayscore = IIf(Avgp > prevdayvaluehigh, 1,
							IIf(Avgp > prevdayvaluelow, 0,
								-1)) ;

		tdayscore = IIf(Avgp > tdayvaluehigh, 2,
							IIf(Avgp > tdayvalue, 1,
							IIf(Avgp > tdayvaluelow, -1,
								-2))) ;

		totalscore = prevdayscore+tdayscore ;

		switch (SelectedValue(prevdayscore))
		{
			case 1: 
				strprevday = "Above VAH " + NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorBlue ;
				break ;
			case 0: 
				strprevday = "In VAL-VH " + NumToStr(SelectedValue(prevdayvaluelow), 1.1) + " - " +  NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorLavender ;
				break ;			
			case -1: 
				strprevday = "Below VAL " + NumToStr(SelectedValue(prevdayvaluelow), 1.1);
				Clrprevday = colorRed ;
				break ;
		}

		switch (SelectedValue(tdayscore))
		{
			case 2: 
				strtday = "Above +1SD " + NumToStr(SelectedValue(tdayvaluehigh), 1.1);
				Clrtday = colorBlue ;
				break ;
			case 1: 
				strtday = "Above VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorSkyblue ;
				break ;			
			case 0: 
				strtday = "VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorLavender ;
				break ;
			case -1: 
				strtday = "Below VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorRose ;
				break ;
			case -2: 
				strtday = "Below -1SD " + NumToStr(SelectedValue(tdayvaluelow), 1.1);
				Clrtday = colorRed ;
				break ;
		}

	fontsz = Param("Font Size", 14, 0, 1000, 1);
	GfxSelectFont( "Tahoma", fontsz, 100 );
	GfxSetBkMode( 1 );
	pxHeight = Status( "pxchartheight" ) ;
	pxWidth = Status( "pxchartwidth");
	dt_flag = 16 /*wordbreak*/;
	textht = 50;
	textwidth = 200 ;
	x = pxWidth - Param("from right edge", 250, 0, 1000, 1) ;
	y = Param("From Top", 50, 0, 1000, 1) ;

	GfxSetTextColor( Clrprevday );
	GfxDrawText(strprevday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y + textht/2 ;
	GfxSetTextColor( Clrtday );
	GfxDrawText(strtday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y ; //+ textht ;
	xbar = x + 150 ;
	Colwidth = 20 ;
	Colht = 30 ;
	tscore = SelectedValue(totalscore) ;

		switch (tscore)
		{
			case 3: 
				strnet = "Strong Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 2: 
				strnet = "Mild Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 1: 
				strnet = "Bull Bias" ;
				Clrnet = colorSkyblue ;
				break ;			
			case 0: 
				strnet = "Neutral" ;
				Clrnet = colorLavender ;
				break ;			
			case -1: 
				strnet = "Bear Bias" ;
				Clrnet = colorRose ;
				break ;
			case -2: 
				strnet = "Mild Bear" ;
				Clrnet = colorRed ;
				break ;
			case -3: 
				strnet = "Strong Bear" ;
				Clrnet = colorRed ;
				break ;
		}

		if (tscore > 0)
		{
			
			GfxSelectSolidBrush(colorBlue) ;
			GfxSelectPen(colorBlue) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*tscore) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*tscore, xbar+Colwidth, y+Colht*3) ;
		}
		else if (tscore == 0)
		{
			
			GfxSelectSolidBrush(colorLavender) ;
			GfxSelectPen(colorLavender) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*3) ;

		}
		else
		{
			
			GfxSelectSolidBrush(colorRed) ;
			GfxSelectPen(colorRed) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*abs(tscore)) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*abs(tscore), xbar+Colwidth, y+Colht*3) ;

		}

		y = y + textht/2 ;
		GfxSetTextColor( Clrnet );
		GfxDrawText(strnet,  x,y, x+textwidth, y+textht , dt_flag) ;

	}

	if (showtext AND NOT nodraw AND NOT showlvls)
	{
		str = Null ;
		if(showtxtlbl)
			str = " +1SD"  ;
		PlotText(NumToStr(RefVwapp1[BarCount-1], 1.1)+str , BarCount+1, RefVwapp1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD"  ;
		PlotText(NumToStr(RefVwapm1[BarCount-1], 1.1)+str , BarCount+1, RefVwapm1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " vwap" ;
		PlotText(NumToStr(RefVwap[BarCount-1], 1.1)+str , BarCount+1, RefVwap[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD"  ;
		PlotText(NumToStr(RefVwapp2[BarCount-1], 1.1)+str , BarCount+1, RefVwapp2[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD"  ;
		PlotText(NumToStr(RefVwapm2[BarCount-1], 1.1)+str , BarCount+1, RefVwapm2[BarCount-1],Clrtext) ;
	}

	if (showvahvaltext AND NOT nodraw)
	{
		str = Null ;
		if(showtxtlbl)
			str = " POC" ; ;
		PlotText(NumToStr(prevdayvalue[BarCount-1] , 1.1)+str, BarCount+1, prevdayvalue[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " VAL" ; ;
		PlotText(NumToStr(prevdayvaluelow[BarCount-1], 1.1)+str , BarCount+1, prevdayvaluelow[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " VAH" ; ;
		PlotText(NumToStr(prevdayvaluehigh[BarCount-1], 1.1)+str , BarCount+1, prevdayvaluehigh[BarCount-1],Clrtext) ;
	}

}
 

pratapvb

Well-Known Member
#9
2dayvwap

Code:
SetChartOptions(2,chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock ("price" x "number of 
      shares traded") and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is 
      calculated by Volume weighting all transactions during this time period

*/
Layer = Param("Layer", 0, -5, 5, 1) ;
showprice = ParamToggle("Show Price", "No|Yes", 0) ;
if (showprice)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g,  " + EncodeColor( colorRed ) + " Lo %g,  " + EncodeColor( colorBlack ) + " Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close",  colorBlack, styleNoTitle | styleCandle,0,0,0,Layer ); 
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False); 
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;
}

farback = Param("Far Back", 500, 1, 10000, 1) ;
SetChartBkColor(colorLightGrey) ;
useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
//List = GetCategorySymbols(categoryMarket, 0) ;
//forscript = ParamList("Scrip", List, 0) ;
forscript = ParamStr("Scrip", "NIFTY_F1") ;
if (useforeign)
	SetForeign(forscript); 

ndays = Param("N Days", 2, 0, 10000, 1) ;
period = Param("Period", 39, 1, 10000, 1) ;
showhalfsd = ParamToggle("Show half SD", "No|Yes", 0) ;
turnvwapoff = ParamToggle("VWAP All OFF", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
nodraw = ParamToggle("No Draw", "No|Yes", 0) ;
showtradearr = ParamToggle("Trade Arrow", "No|Yes", 0) ;
Filterdaych = ParamToggle("Filter Day Change Connections", "No|Yes", 1) ;

Vwapmode = ParamList("VWAP mode", "As Per Param|Only VWAP|VWAP+SD|VWAP+2SD", 0) ;
showvwap = ParamToggle("Show VWAP", "No|Yes", 1) ;
showvwap1sd = ParamToggle("Show VWAP 1SD", "No|Yes", 1) ;
showvwap2sd = ParamToggle("Show VWAP 2SD", "No|Yes", 1) ;
showvwap3sd = ParamToggle("Show VWAP 3SD", "No|Yes", 0) ;
showvwapband = ParamToggle("Show VWAP Trend Bands", "No|Yes", 1) ;
showvwapswband = ParamToggle("Show VWAP Sideways Bands", "No|Yes", 0) ;
showprevdayvals = ParamToggle("Show Prev Day Values", "No|Yes", 1) ;
showprev2dayvals = ParamToggle("Show Prev 2 Day Values", "No|Yes", 1) ;
showprevdayband = ParamToggle("Show Prev Day Bands", "No|Yes", 0) ;
showextprevday = ParamToggle("Show Extension", "No|Yes", 1)  ;
showextbandprevday = ParamToggle("Show Extension Band", "No|Yes", 1)  ;
extend = Param("Extend", 15, 0, 100, 1) ;

showextvwap = ParamToggle("Show VWAP Extension", "No|Yes", 1)  ;
vwapextend = Param("VWAP Extend", 15, 0, 100, 1) ;
showexttrndband = ParamToggle("Show Trend Band Extension", "No|Yes", 1)  ;
trndbandextend = Param("Trend Band Extend", 10, 0, 100, 1) ;
showextswband = ParamToggle("Show Sidewways Band Extension", "No|Yes", 0)  ;
swbandextend = Param("Sideways Band Extend", 10, 0, 100, 1) ;
showlvltext = ParamToggle("Show Level Text", "No|Yes", 1) ;

Vwaplayer = Param("VWAP Layer", -3, -5, 5, 1) ;
extlayer = Param("Extend Layer", -2, -5, 5, 1) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
SDwidthper = Param("SD Width %", 0.01, 0, 10, 1) ;
SDwidth = SelectedValue(C) * SDwidthper /100 ;
SD2widthper = Param("SD2 Width %", 0.005, 0, 10, 1) ;
SD2width = SelectedValue(C) * SD2widthper /100 ;

showcomm = ParamToggle("Show Commentary", "No|Yes", 0) ;
showtext = ParamToggle("Show Text", "No|Yes", 1) ;
Clrtext = ParamColor("Color Text", colorBlack) ;
showvahvaltext = ParamToggle("Show VAH-VAL Text", "No|Yes", 1) ;
showtxtlbl = ParamToggle("Show Text Label", "No|Yes", 1) ;


Onlyvwap = False ;
withsd = False ;
with2sd = False ;

switch (Vwapmode)
{
	case "As Per Param":
		break ;
	case "Only VWAP" :
		Onlyvwap = True ;
		break ;
	case "VWAP+SD" :
		Onlyvwap = True ;
		withsd = True;
		break ;
	case "VWAP+2SD" :
		Onlyvwap = True ;
		withsd = True;
		with2sd = True;
		break ;
}

if (Onlyvwap)
{	
	if (withsd)
		showvwap1sd = True;
	else
		showvwap1sd = False ;
	if (with2sd)
		showvwap2sd = True;
	else
		showvwap2sd = False ;
	showvwap3sd = False ;
//	showvwapband = False ;
//	showvwapswband = False ;
//	showprevdayvals = False ;
//	showprev2dayvals = False ;
//	showprevdayband = False ;

//	showtradearr = False ;
	showcomm = False ;
	showtext = withsd ;
}

stylelabel = 0 ;
if (showtext)
	stylelabel = styleNoLabel ;

styletitle = 0 ;
if (NOT showintitle)
	styletitle = styleNoTitle ;

styledata = 0 ;
if (nodraw)
{
	styledata = styleNoDraw ;
//showtradearr = False ;
}
//SetBarsRequired(int(farback*1.1)) ;

if (NOT turnvwapoff)
{
P = (H + L + C) / 3;
nd = Day() != Ref(Day(),-1) ;
Bars_so_far_today = 1 + BarsSince( nd);
if (ndays == 0)
	Bars_so_far_today = IIf(Bars_so_far_today < period, Bars_so_far_today, period) ;
else if (ndays > 1)
{
	bi = BarIndex() ;
/*
	bivwap0 = ValueWhen(nd, bi, ndays) ;
	bivwap1 = ValueWhen(nd, bi, ndays+1) ;

	dttn = DateTime() ;
	tnhr = DateTimeConvert(5, dttn) ;
	
	bivwap = IIf(tnhr < 12, bivwap1, bivwap0) ;
	Bars_so_far_today	 = 1 + (bi - bivwap) ;
*/
	bivwap = ValueWhen(nd, bi, ndays) ;
	nbar = (bi - bivwap) ;

	Bars_so_far_today	 = ValueWhen(nd, nbar, 1) *ndays ;
//	Bars_so_far_today	 = 375*ndays ;

}

//StartBar = ValueWhen(TimeNum() == 091600, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
//IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today  ) / TodayVolume,0);
//Plot (VWAP,"VWAP",colorBlack, styleThick);

	CumV = Sum(V,Bars_so_far_today);
	CumVWP = Sum (P * V, Bars_so_far_today  );
   VWAP = CumVWP / CumV;
//	S = Sum(Ref(CumV, 0) * V * (P - Ref(VWAP, 0))^2,Bars_so_far_today) / CumV;
	VWAPsd = IIf(Ref(nd, 1), 0, VWAP);
	CumVsd = IIf(Ref(nd, 1), 0, CumV);

	S = Sum(Ref(CumVsd, -1) * V * (P - Ref(VWAPsd, -1))^2 / CumV,Bars_so_far_today);
	Variance = S / CumV;
	 SD = sqrt(Variance);
//	 VWAP = IIf(InRange,  VWAP, Null);
	Vwapm1 = VWAP - SD ;
	Vwapp1 = VWAP + SD ;
	Vwapm2 = VWAP -2*SD ;
	Vwapp2 = VWAP +2*SD ;
	Vwapm3 = VWAP -3*SD ;
	Vwapp3 = VWAP +3*SD ;

	Vwapm05 = VWAP - 0.5*SD ;
	Vwapp05 = VWAP + 0.5*SD ;
	Vwapm15 = VWAP -1.5*SD ;
	Vwapp15 = VWAP +1.5*SD ;
	Vwapm25 = VWAP -2.5*SD ;
	Vwapp25 = VWAP +2.5*SD ;

	showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
	Refo = ParamField("CRB Open", 7+0) ;
	Refh = ParamField("CRB High", 7+1) ;
	Refl = ParamField("CRB Low", 7+2) ;
	Refc = ParamField("CRB Close", 7+3) ;
	Refbi = ParamField("CRB BI", 7+4) ;
	Refcrbbars = ParamField("CRB Bars", 7+5) ;
	Refnbars = ParamField("TF Bars", 7+6) ;
	Refdt = ParamField("CRB DT", 7+7) ;

	if (showoncrb)
		dt = Refdt ;
	else
		dt = DateTime() ;

	dtnum = DateTimeConvert(0, dt) ;
	newdt = dtnum != Ref(dtnum, -1) ;

	Lastbar = H-H ;
	if (Filterdaych)
		Lastbar = dtnum != Ref(dtnum, 1) ;

	if (showoncrb)
	{
		diffbars = Refnbars -Refcrbbars -1 ;
		Crbst = BarCount - LastValue(Refcrbbars) -1;
		// convert to crb
		RefVWAP = Ref(VWAP, -diffbars) ;
		RefVwapm1 = Ref(Vwapm1, -diffbars) ;
		RefVwapp1 = Ref(Vwapp1, -diffbars) ;
		RefVwapm2 = Ref(Vwapm2, -diffbars) ;
		RefVwapp2 = Ref(Vwapp2, -diffbars) ;
		RefVwapm3 = Ref(Vwapm3, -diffbars) ;
		RefVwapp3 = Ref(Vwapp3, -diffbars) ;

		k = 0 ;
		for ( i = Crbst ; i < BarCount ; i++)
		{
			Refbar = Refbi[i];

			RefVWAP[i] = VWAP[Refbar] ;
			RefVwapm1[i] = Vwapm1[Refbar] ;
			RefVwapp1[i] = Vwapp1[Refbar] ;
			RefVwapm2[i] = Vwapm2[Refbar] ;
			RefVwapp2[i] = Vwapp2[Refbar] ;
			RefVwapm3[i] = Vwapm3[Refbar] ;
			RefVwapp3[i] = Vwapp3[Refbar] ;

			RefVwapm05[i] = Vwapm05[Refbar] ;
			RefVwapp05[i] = Vwapp05[Refbar] ;
			RefVwapm15[i] = Vwapm15[Refbar] ;
			RefVwapp15[i] = Vwapp15[Refbar] ;
			RefVwapm25[i] = Vwapm25[Refbar] ;
			RefVwapp25[i] = Vwapp25[Refbar] ;
			k++;
		}
	}
	else
	{
			RefVWAP = VWAP;
			RefVwapm1 = Vwapm1;
			RefVwapp1 = Vwapp1 ;
			RefVwapm2 = Vwapm2;
			RefVwapp2 = Vwapp2;
			RefVwapm3 = Vwapm3;
			RefVwapp3 = Vwapp3;

			RefVwapm05 = Vwapm05;
			RefVwapp05 = Vwapp05 ;
			RefVwapm15 = Vwapm15;
			RefVwapp15 = Vwapp15;
			RefVwapm25 = Vwapm25;
			RefVwapp25 = Vwapp25;
	}

	Clrvwap =  ParamColor("Color VWAP",colorBlue) ;
	Clrvwapm1 = ParamColor("Color VWAP -1SD", colorViolet) ;
	Clrvwapp1 = ParamColor("Color VWAP +1SD", colorViolet) ;

	strnday = NumToStr(ndays, 1.0)+"day";

		styleshow = IIf(showvwap, 0, styleNoDraw) ;
//		Vwapstyle = 0 ;
//		if (ndays > 1)
			Vwapstyle = styleNoRescale ;
		Plot(IIf(Lastbar, Null, RefVWAP), "VWAP"+strnday, Clrvwap , styleThick|stylelabel|Vwapstyle|styledata|styleshow, Null, Null, 0, 1);
		if (MAwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 1 ) ;

	Plot(SD, "SD", colorBlack, styleNoDraw|styleNoLabel|styleNoRescale) ;

		styleshow = IIf(showvwap1sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm1), "-1SD"+strnday, Clrvwapm1,  styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp1), "+1SD"+strnday, Clrvwapp1, styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;


		styleshow = IIf(showvwap2sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm2), "-2SD"+strnday, ParamColor("Color VWAP -2SD", colorViolet), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp2), "+2SD"+strnday, ParamColor("Color VWAP +2SD", colorViolet), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), "",ParamColor("Color VWAP -2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), "",ParamColor("Color VWAP +2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		styleshow = IIf(showvwap3sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm3), "-3SD"+strnday, ParamColor("Color VWAP -3SD", colorViolet), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp3), "+3SD"+strnday, ParamColor("Color VWAP +3SD", colorViolet), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);

		styleshow = IIf(showhalfsd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm05), "-0.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp05), "+0.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapm15), "-1.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp15), "+1.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapm25), "-2.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp25), "+2.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);



		styleshow = IIf(showvwapband, 0, styleNoDraw) ;
		dnclr = ParamColor("Down Trend", colorPink) ;
		upclr = ParamColor("Up Trend", colorSkyblue) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm2), IIf(Lastbar, Null, RefVwapm2), "",ParamColor("Down Trend", colorPink), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp2), IIf(Lastbar, Null, RefVwapp2), "",ParamColor("Up Trend", colorPaleTurquoise), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		if (showexttrndband)
		{
			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			x0 = BarCount - (trndbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp2) ;
			Ldlast = SelectedValue(RefVwapp1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", upclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;

			Hdlast = SelectedValue(RefVwapm1) ;
			Ldlast = SelectedValue(RefVwapm2) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;

			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", dnclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;
		}


		styleshow = IIf(showextvwap, 0, styleNoDraw) ;
		x0 = BarCount - (vwapextend+1)+1 ;
		x1 = BarCount -1 ;

		vwaplast = SelectedValue(RefVWAP) ;
		p1last = SelectedValue(RefVwapp1) ;
		m1last = SelectedValue(RefVwapm1) ;
		p2last = SelectedValue(RefVwapp2) ;
		m2last = SelectedValue(RefVwapm2) ;
showlvls = True ;
		vwapextPlot = LineArray(x0, vwaplast , x1, vwaplast ) ;
		Plot(vwapextPlot , "", Clrvwap, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (MAwidth > 0)
			PlotOHLC(vwapextPlot +MAwidth, vwapextPlot +MAwidth, vwapextPlot -MAwidth, vwapextPlot -MAwidth, "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " 2dvwap"  ;
		if (showlvltext)
			PlotText(NumToStr(vwaplast , 8.1)+str, BarCount+Vwapextend-3, vwaplast , colorBlack) ;

		p1extPlot = LineArray(x0, p1last , x1, p1last ) ;
		Plot(p1extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(p1extPlot +SDwidth , p1extPlot +SDwidth , p1extPlot -SDwidth , p1extPlot -SDwidth , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +1SD2"  ;
		if (showlvltext)
			PlotText(NumToStr(p1last, 8.1)+str, BarCount+Vwapextend-3, p1last , colorBlack) ;

		m1extPlot = LineArray(x0, m1last , x1, m1last ) ;
		Plot(m1extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(m1extPlot +SDwidth , m1extPlot +SDwidth , m1extPlot -SDwidth , m1extPlot -SDwidth , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD2"  ;
		if (showlvltext)
			PlotText(NumToStr(m1last , 8.1)+str, BarCount+Vwapextend-3, m1last , colorBlack) ;

		p2extPlot = LineArray(x0, p2last , x1, p2last ) ;
		Plot(p2extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(p2extPlot +SD2width , p2extPlot +SD2width , p2extPlot -SD2width , p2extPlot -SD2width , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD2"  ;
		if (showlvltext)
			PlotText(NumToStr(p2last , 8.1)+str, BarCount+Vwapextend-3, p2last , colorBlack) ;

		m2extPlot = LineArray(x0, m2last , x1, m2last ) ;
		Plot(m2extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(m2extPlot +SD2width , m2extPlot +SD2width , m2extPlot -SD2width , m2extPlot -SD2width , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD2"  ;
		if (showlvltext)
			PlotText(NumToStr(m2last , 8.1)+str, BarCount+Vwapextend-3, m2last, colorBlack) ;

		styleshow = IIf(showhalfsd, 0, styleNoDraw) ;
		p05last = SelectedValue(RefVwapp05) ;
		m05last = SelectedValue(RefVwapm05) ;
		p15last = SelectedValue(RefVwapp15) ;
		m15last = SelectedValue(RefVwapm15) ;
		p25last = SelectedValue(RefVwapp25) ;
		m25last = SelectedValue(RefVwapm25) ;

		m05extPlot = LineArray(x0, m05last , x1, m05last ) ;
		Plot(m05extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p05extPlot = LineArray(x0, p05last , x1, p05last ) ;
		Plot(p05extPlot, "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		m15extPlot = LineArray(x0, m15last , x1, m15last ) ;
		Plot(m15extPlot, "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p15extPlot = LineArray(x0, p15last , x1, p15last ) ;
		Plot(p15extPlot, "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		m25extPlot = LineArray(x0, m25last , x1, m25last ) ;
		Plot(m25extPlot, "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p25extPlot = LineArray(x0, p25last , x1, p25last ) ;
		Plot(p25extPlot, "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;

		if (showlvltext)
		{
		str = Null ;
		if(showtxtlbl)
			str = " -0.5SD2"  ;
		PlotText(NumToStr(m05last , 8.1)+str, BarCount+Vwapextend-3, m05last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +0.5SD2"  ;
		PlotText(NumToStr(p05last , 8.1)+str, BarCount+Vwapextend-3, p05last , colorBlack) ;

		str = Null ;
		if(showtxtlbl)
			str = " -1.5SD2"  ;
		PlotText(NumToStr(m15last , 8.1)+str, BarCount+Vwapextend-3, m15last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +1.5SD2"  ;
		PlotText(NumToStr(p15last , 8.1)+str, BarCount+Vwapextend-3, p15last , colorBlack) ;

		str = Null ;
		if(showtxtlbl)
			str = " -2.5SD2"  ;
		PlotText(NumToStr(m25last, 8.1)+str, BarCount+Vwapextend-3, m25last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2.5SD2"  ;
		PlotText(NumToStr(p25last , 8.1)+str, BarCount+Vwapextend-3, p25last , colorBlack) ;
		}

		if (showoncrb)
		{
			Ht = Refh ;
			Lt = Refl ;
			Ct = Refc ;
		}
		else
		{
			Ht = H ;
			Lt = L ;
			Ct = C ;
		}

		Avgp = (Ht+Lt+Ct)/3 ;

	if (showtradearr)
	{

		Buy = Avgp >= Refvwapp1 ;
		Short = Avgp <= Refvwapm1 ;

		Sell =  Avgp <= Refvwapp1 ;
		Cover = Avgp >= Refvwapm1 ;

		Buy = ExRem(Buy, Short OR Sell) ;
		Short = ExRem(Short, Buy OR Cover) ;

		sdp1touch = False ; // Ht >= Refvwapp1 ;
		sdm1touch = False ; //Lt >= Refvwapm1 ;

		Sell = ExRem(Sell, Buy OR sdp1touch ) ;
		Cover = ExRem(Cover, Short OR sdm1touch ) ;

		PlotShapes(Cover*shapeUpArrow, colorViolet, 0, Ht, 12) ;
		PlotShapes(Sell*shapeDownArrow, colorViolet, 0, Lt, 12) ;

		PlotShapes(Buy*shapeUpArrow, colorViolet, 0, Ht, 12) ;
		PlotShapes(Short*shapeDownArrow, colorViolet, 0, Lt, 12) ;

	}

	shift = Param("Shift", 0, -1, 0, 1) ;

	prevdayvalue = prevdayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 1) ;
	prevdayvaluelow = prevdayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 1) ;
	prevdayvaluehigh = prevdayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 1) ;
	prevdayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 1) ;

		styleshow = IIf(showvwapswband, 0, styleNoDraw) ;
		swclr = ParamColor("Sideways Color", colorLavender) ;
		upclr =  ParamColor("Bull Bias Color", colorSkyblue) ;
		dnclr =  ParamColor("Bear Bias Color", colorRose) ;

		if (ndays >= 1)
		{

			bandclr = IIf(Refvwap < prevdayvaluelow, dnclr, IIf(Refvwap > prevdayvaluehigh, upclr, swclr)) ;

			
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
			
		if (showextswband)
		{
			styleshow = IIf(showextprevday, 0, styleNoDraw) ;
			x0 = BarCount - (swbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp1) ;
			Ldlast = SelectedValue(RefVwapm1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextswband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", bandclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,swbandextend ,extlayer ) ;

		}


		}
		else
				PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), "",swclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;


		if (shift == -1)
		{
			prevdayvaluehigh = prevdayvwap;
			prevdayvalue = prevdayvwapm1 ;
			prevdayvaluelow = prevdayvwapm2 ;
		}

		styleshow = IIf(showprevdayvals, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, prevdayvalue), "Prev VWAP", Clrvwap, styleDots|styleNoRescale+stylelabel|styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluelow), "VAL"+strnday, Clrvwapm1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluehigh), "VAH"+strnday, Clrvwapp1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;

		Clrprevdayband = ParamColor("Prev Day Band Color", colorRose);
			styleshow = IIf(showprevdayband, 0, styleNoDraw) ;
			PlotOHLC(IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluehigh), IIf(Lastbar, Null, prevdayvaluehigh), "",Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;


			styleshow = IIf(showprev2dayvals, 0, styleNoDraw) ;
			prev2dayvalue = prev2dayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 2) ;
			prev2dayvaluelow = prev2dayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 2) ;
			prev2dayvaluehigh = prev2dayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 2) ;
			prev2dayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 2) ;

			Plot(IIf(Lastbar, Null, prev2dayvalue), "2day prev VWAP"+strnday, Clrvwap, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluelow), "2day VAL"+strnday, Clrvwapm1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluehigh), "2day VAH"+strnday, Clrvwapp1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;


		styleshow = IIf(showextprevday, 0, styleNoDraw) ;
		x0 = BarCount - (extend+1)+1 ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(prevdayvaluehigh ) ;
		Ldlast = SelectedValue(prevdayvaluelow ) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "VAHext"+strnday, colorViolet, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "VALext"+strnday, colorViolet, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextbandprevday, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrprevdayband, styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend,extlayer ) ;


		showvwaptrend = ParamToggle("Show VWAP Trend", "No|Yes", 0) ;
		styleshow = IIf(showvwaptrend, 0, styleNoDraw) ;
		up = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 >= Ref(RefVwapm1, -1);
		down = RefVwapp1 <= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1) ;
		expand = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1);


		Clr = IIf(up AND down, colorLavender, IIf(up, colorBlue, IIf(down, colorRed, IIf(expand, IIf(Ct > RefVwap, colorGreen, colorLightOrange), colorLavender)))) ;

		Plot(4, "", Clr, styleArea|styleNoLabel|styleOwnScale|styledata|styleshow, 0, 100,-1) ;


	
	if (showcomm AND NOT nodraw)
	{
		tdayvalue = RefVWAP ;
		tdayvaluehigh = Refvwapp1 ;
		tdayvaluelow = Refvwapm1 ;

		prevdayscore = IIf(Avgp > prevdayvaluehigh, 1,
							IIf(Avgp > prevdayvaluelow, 0,
								-1)) ;

		tdayscore = IIf(Avgp > tdayvaluehigh, 2,
							IIf(Avgp > tdayvalue, 1,
							IIf(Avgp > tdayvaluelow, -1,
								-2))) ;

		totalscore = prevdayscore+tdayscore ;

		switch (SelectedValue(prevdayscore))
		{
			case 1: 
				strprevday = "Above Prev Day Value High " + NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorBlue ;
				break ;
			case 0: 
				strprevday = "In Prev Day Value Range " + NumToStr(SelectedValue(prevdayvaluelow), 1.1) + " - " +  NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorLavender ;
				break ;			
			case -1: 
				strprevday = "Below Prev Day Value Low " + NumToStr(SelectedValue(prevdayvaluelow), 1.1);
				Clrprevday = colorRed ;
				break ;
		}

		switch (SelectedValue(tdayscore))
		{
			case 2: 
				strtday = "Above Day Value High " + NumToStr(SelectedValue(tdayvaluehigh), 1.1);
				Clrtday = colorBlue ;
				break ;
			case 1: 
				strtday = "Above Day VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorSkyblue ;
				break ;			
			case 0: 
				strtday = "VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorLavender ;
				break ;
			case -1: 
				strtday = "Below Day VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorRose ;
				break ;
			case -2: 
				strtday = "Below Day Value Low " + NumToStr(SelectedValue(tdayvaluelow), 1.1);
				Clrtday = colorRed ;
				break ;
		}

	fontsz = Param("Font Size", 14, 0, 1000, 1);
	GfxSelectFont( "Tahoma", fontsz, 100 );
	GfxSetBkMode( 1 );
	pxHeight = Status( "pxchartheight" ) ;
	pxWidth = Status( "pxchartwidth");
	dt_flag = 16 /*wordbreak*/;
	textht = 75;
	textwidth = 150 ;
	x = pxWidth - Param("from right edge", 250, 0, 1000, 1) ;
	y = Param("From Top", 50, 0, 1000, 1) ;

	GfxSetTextColor( Clrprevday );
	GfxDrawText(strprevday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y + textht ;
	GfxSetTextColor( Clrtday );
	GfxDrawText(strtday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y ; //+ textht ;
	xbar = x + 150 ;
	Colwidth = 40 ;
	Colht = 75 ;
	tscore = SelectedValue(totalscore) ;

		switch (tscore)
		{
			case 3: 
				strnet = "Strong Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 2: 
				strnet = "Mild Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 1: 
				strnet = "Bull Bias" ;
				Clrnet = colorSkyblue ;
				break ;			
			case 0: 
				strnet = "Neutral" ;
				Clrnet = colorLavender ;
				break ;			
			case -1: 
				strnet = "Bear Bias" ;
				Clrnet = colorRose ;
				break ;
			case -2: 
				strnet = "Mild Bear" ;
				Clrnet = colorRed ;
				break ;
			case -3: 
				strnet = "Strong Bear" ;
				Clrnet = colorRed ;
				break ;
		}

		if (tscore > 0)
		{
			
			GfxSelectSolidBrush(colorBlue) ;
			GfxSelectPen(colorBlue) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*tscore) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*tscore, xbar+Colwidth, y+Colht*3) ;
		}
		else if (tscore == 0)
		{
			
			GfxSelectSolidBrush(colorLavender) ;
			GfxSelectPen(colorLavender) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*3) ;

		}
		else
		{
			
			GfxSelectSolidBrush(colorRed) ;
			GfxSelectPen(colorRed) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*abs(tscore)) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*abs(tscore), xbar+Colwidth, y+Colht*3) ;

		}

		y = y + textht ;
		GfxSetTextColor( Clrnet );
		GfxDrawText(strnet,  x,y, x+textwidth, y+textht , dt_flag) ;

	}

	if (showtext AND NOT nodraw AND NOT showlvls)
	{
		str = Null ;
		if(showtxtlbl)
			str = " +1SD2"  ;
		PlotText(NumToStr(RefVwapp1[BarCount-1], 1.1)+str , BarCount+1, RefVwapp1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD2"  ;
		PlotText(NumToStr(RefVwapm1[BarCount-1], 1.1)+str , BarCount+1, RefVwapm1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " 2dvwap" ;
		PlotText(NumToStr(RefVwap[BarCount-1], 1.1)+str , BarCount+1, RefVwap[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD2"  ;
		PlotText(NumToStr(RefVwapp2[BarCount-1], 1.1)+str , BarCount+1, RefVwapp2[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD2"  ;
		PlotText(NumToStr(RefVwapm2[BarCount-1], 1.1)+str , BarCount+1, RefVwapm2[BarCount-1],Clrtext) ;

		if (showhalfsd)
		{
			str = Null ;
			if(showtxtlbl)
				str = " +0.5SD2"  ;
			PlotText(NumToStr(RefVwapp05[BarCount-1], 1.1)+str, BarCount+1, RefVwapp05[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -0.5SD2"  ;
			PlotText(NumToStr(RefVwapm05[BarCount-1], 1.1)+str, BarCount+1, RefVwapm05[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " +1.5SD2"  ;
			PlotText(NumToStr(RefVwapp15[BarCount-1], 1.1)+str, BarCount+1, RefVwapp15[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -1.5SD2"  ;
			PlotText(NumToStr(RefVwapm15[BarCount-1], 1.1)+str, BarCount+1, RefVwapm15[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " +2.5SD2"  ;
			PlotText(NumToStr(RefVwapp25[BarCount-1], 1.1)+str, BarCount+1, RefVwapp25[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -2.5SD2"  ;
			PlotText(NumToStr(RefVwapm25[BarCount-1], 1.1)+str, BarCount+1, RefVwapm25[BarCount-1],Clrtext) ;
		}
	}

	if (showvahvaltext AND NOT nodraw)
	{
		str = Null ;
		if(showtxtlbl)
			str = " POC2" ; ;
		PlotText(NumToStr(prevdayvalue[BarCount-1], 1.1)+str, BarCount+1, prevdayvalue[BarCount-1],Clrtext) ;

		str = Null ;
		if(showtxtlbl)
			str = " VAL2" ; ;

		PlotText(NumToStr(prevdayvaluelow[BarCount-1], 1.1)+str, BarCount+1, prevdayvaluelow[BarCount-1],Clrtext) ;

		str = Null ;
		if(showtxtlbl)
			str = " VAH2" ; ;

		PlotText(NumToStr(prevdayvaluehigh[BarCount-1], 1.1)+str, BarCount+1, prevdayvaluehigh[BarCount-1],Clrtext) ;
	}

	scalefactor = 0 ;
	if (scalefactor > 0 AND nDays <= 1)
	{
		Plot(SelectedValue(Ct)+scalefactor*SD, "", colorBlack, styleNoDraw) ;
		Plot(SelectedValue(Ct)-scalefactor*SD, "", colorBlack, styleNoDraw) ;
	}
}
 

pratapvb

Well-Known Member
#10
5dayvwap

Code:
SetChartOptions(2,chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock ("price" x "number of 
      shares traded") and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is 
      calculated by Volume weighting all transactions during this time period

*/
Layer = Param("Layer", 0, -5, 5, 1) ;
showprice = ParamToggle("Show Price", "No|Yes", 0) ;
if (showprice)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g,  " + EncodeColor( colorRed ) + " Lo %g,  " + EncodeColor( colorBlack ) + " Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close",  colorBlack, styleNoTitle | styleCandle,0,0,0,Layer ); 
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False); 
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;
}

farback = Param("Far Back", 500, 1, 10000, 1) ;
SetChartBkColor(colorLightGrey) ;
useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
//List = GetCategorySymbols(categoryMarket, 0) ;
//forscript = ParamList("Scrip", List, 0) ;
forscript = ParamStr("Scrip", "NIFTY_F1") ;
if (useforeign)
	SetForeign(forscript); 

ndays = Param("N Days", 5, 0, 10000, 1) ;
period = Param("Period", 39, 1, 10000, 1) ;
showhalfsd = ParamToggle("Show half SD", "No|Yes", 1) ;
turnvwapoff = ParamToggle("VWAP All OFF", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
nodraw = ParamToggle("No Draw", "No|Yes", 0) ;
showtradearr = ParamToggle("Trade Arrow", "No|Yes", 0) ;
Filterdaych = ParamToggle("Filter Day Change Connections", "No|Yes", 0) ;

Vwapmode = ParamList("VWAP mode", "As Per Param|Only VWAP|VWAP+SD|VWAP+2SD", 0) ;
showvwap = ParamToggle("Show VWAP", "No|Yes", 1) ;
showvwap1sd = ParamToggle("Show VWAP 1SD", "No|Yes", 1) ;
showvwap2sd = ParamToggle("Show VWAP 2SD", "No|Yes", 1) ;
showvwap3sd = ParamToggle("Show VWAP 3SD", "No|Yes", 1) ;
showvwapband = ParamToggle("Show VWAP Trend Bands", "No|Yes", 1) ;
showvwapswband = ParamToggle("Show VWAP Sideways Bands", "No|Yes", 0) ;
showprevdayvals = ParamToggle("Show Prev Day Values", "No|Yes", 0) ;
showprev2dayvals = ParamToggle("Show Prev 2 Day Values", "No|Yes", 0) ;
showprevdayband = ParamToggle("Show Prev Day Bands", "No|Yes", 0) ;
showextprevday = ParamToggle("Show Extension", "No|Yes", 1)  ;
showextbandprevday = ParamToggle("Show Extension Band", "No|Yes", 0)  ;
extend = Param("Extend", 15, 0, 100, 1) ;

showextvwap = ParamToggle("Show VWAP Extension", "No|Yes", 1)  ;
vwapextend = Param("VWAP Extend", 15, 0, 100, 1) ;
showexttrndband = ParamToggle("Show Trend Band Extension", "No|Yes", 0)  ;
trndbandextend = Param("Trend Band Extend", 10, 0, 100, 1) ;
showextswband = ParamToggle("Show Sidewways Band Extension", "No|Yes", 0)  ;
swbandextend = Param("Sideways Band Extend", 10, 0, 100, 1) ;
showlvltext = ParamToggle("Show Level Text", "No|Yes", 1) ;


Vwaplayer = Param("VWAP Layer", -3, -5, 5, 1) ;
extlayer = Param("Extend Layer", -2, -5, 5, 1) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
SDwidthper = Param("SD Width %", 0.01, 0, 10, 1) ;
SDwidth = SelectedValue(C) * SDwidthper /100 ;
SD2widthper = Param("SD2 Width %", 0.005, 0, 10, 1) ;
SD2width = SelectedValue(C) * SD2widthper /100 ;

showcomm = ParamToggle("Show Commentary", "No|Yes", 0) ;
showtext = ParamToggle("Show Text", "No|Yes", 1) ;
Clrtext = ParamColor("Color Text", colorBlack) ;
showvahvaltext = ParamToggle("Show VAH-VAL Text", "No|Yes", 1) ;
showtxtlbl = ParamToggle("Show Text Label", "No|Yes", 1) ;

Onlyvwap = False ;
withsd = False ;
with2sd = False ;

switch (Vwapmode)
{
//	case "As Per Param":
//		break ;
	case "Only VWAP" :
		Onlyvwap = True ;
		break ;
	case "VWAP+SD" :
		Onlyvwap = True ;
		withsd = True;
		break ;
	case "VWAP+2SD" :
		Onlyvwap = True ;
		withsd = True;
		with2sd = True;
		break ;
}

if (Onlyvwap)
{	
	if (withsd)
		showvwap1sd = True;
	else
		showvwap1sd = False ;
	if (with2sd)
		showvwap2sd = True;
	else
		showvwap2sd = False ;
	showvwap3sd = False ;
//	showvwapband = False ;
//	showvwapswband = False ;
//	showprevdayvals = False ;
//	showprev2dayvals = False ;
//	showprevdayband = False ;

//	showtradearr = False ;
	showcomm = False ;
	showtext = withsd ;
}

stylelabel = 0 ;
if (showtext)
	stylelabel = styleNoLabel ;

styletitle = 0 ;
if (NOT showintitle)
	styletitle = styleNoTitle ;

styledata = 0 ;
if (nodraw)
{
	styledata = styleNoDraw ;
//showtradearr = False ;
}
//SetBarsRequired(int(farback*1.1)) ;

if (NOT turnvwapoff)
{
P = (H + L + C) / 3;
nd = Day() != Ref(Day(),-1) ;
Bars_so_far_today = 1 + BarsSince( nd);
if (ndays == 0)
	Bars_so_far_today = IIf(Bars_so_far_today < period, Bars_so_far_today, period) ;
else if (ndays > 1)
{
	bi = BarIndex() ;
/*
	bivwap0 = ValueWhen(nd, bi, ndays) ;
	bivwap1 = ValueWhen(nd, bi, ndays+1) ;

	dttn = DateTime() ;
	tnhr = DateTimeConvert(5, dttn) ;
	
	bivwap = IIf(tnhr < 12, bivwap1, bivwap0) ;
	Bars_so_far_today	 = 1 + (bi - bivwap) ;
*/
	bivwap = ValueWhen(nd, bi, ndays) ;
	nbar = (bi - bivwap) ;

	Bars_so_far_today	 = ValueWhen(nd, nbar, 1) *ndays ;
//	Bars_so_far_today	 = 375*ndays ;

}

//StartBar = ValueWhen(TimeNum() == 091600, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
//IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today  ) / TodayVolume,0);
//Plot (VWAP,"VWAP",colorBlack, styleThick);

	CumV = Sum(V,Bars_so_far_today);
	CumVWP = Sum (P * V, Bars_so_far_today  );
   VWAP = CumVWP / CumV;
//	S = Sum(Ref(CumV, 0) * V * (P - Ref(VWAP, 0))^2,Bars_so_far_today) / CumV;
	VWAPsd = IIf(Ref(nd, 1), 0, VWAP);
	CumVsd = IIf(Ref(nd, 1), 0, CumV);

	S = Sum(Ref(CumVsd, -1) * V * (P - Ref(VWAPsd, -1))^2 / CumV,Bars_so_far_today);
	Variance = S / CumV;
	 SD = sqrt(Variance);
//	 VWAP = IIf(InRange,  VWAP, Null);
	Vwapm1 = VWAP - SD ;
	Vwapp1 = VWAP + SD ;
	Vwapm2 = VWAP -2*SD ;
	Vwapp2 = VWAP +2*SD ;
	Vwapm3 = VWAP -3*SD ;
	Vwapp3 = VWAP +3*SD ;

	Vwapm05 = VWAP - 0.5*SD ;
	Vwapp05 = VWAP + 0.5*SD ;
	Vwapm15 = VWAP -1.5*SD ;
	Vwapp15 = VWAP +1.5*SD ;
	Vwapm25 = VWAP -2.5*SD ;
	Vwapp25 = VWAP +2.5*SD ;

	showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
	Refo = ParamField("CRB Open", 7+0) ;
	Refh = ParamField("CRB High", 7+1) ;
	Refl = ParamField("CRB Low", 7+2) ;
	Refc = ParamField("CRB Close", 7+3) ;
	Refbi = ParamField("CRB BI", 7+4) ;
	Refcrbbars = ParamField("CRB Bars", 7+5) ;
	Refnbars = ParamField("TF Bars", 7+6) ;
	Refdt = ParamField("CRB DT", 7+7) ;

	if (showoncrb)
		dt = Refdt ;
	else
		dt = DateTime() ;

	dtnum = DateTimeConvert(0, dt) ;
	newdt = dtnum != Ref(dtnum, -1) ;

	Lastbar = H-H ;
	if (Filterdaych)
		Lastbar = dtnum != Ref(dtnum, 1) ;

	if (showoncrb)
	{
		diffbars = Refnbars -Refcrbbars -1 ;
		Crbst = BarCount - LastValue(Refcrbbars) -1;
		// convert to crb
		RefVWAP = Ref(VWAP, -diffbars) ;
		RefVwapm1 = Ref(Vwapm1, -diffbars) ;
		RefVwapp1 = Ref(Vwapp1, -diffbars) ;
		RefVwapm2 = Ref(Vwapm2, -diffbars) ;
		RefVwapp2 = Ref(Vwapp2, -diffbars) ;
		RefVwapm3 = Ref(Vwapm3, -diffbars) ;
		RefVwapp3 = Ref(Vwapp3, -diffbars) ;

		k = 0 ;
		for ( i = Crbst ; i < BarCount ; i++)
		{
			Refbar = Refbi[i];

			RefVWAP[i] = VWAP[Refbar] ;
			RefVwapm1[i] = Vwapm1[Refbar] ;
			RefVwapp1[i] = Vwapp1[Refbar] ;
			RefVwapm2[i] = Vwapm2[Refbar] ;
			RefVwapp2[i] = Vwapp2[Refbar] ;
			RefVwapm3[i] = Vwapm3[Refbar] ;
			RefVwapp3[i] = Vwapp3[Refbar] ;

			RefVwapm05[i] = Vwapm05[Refbar] ;
			RefVwapp05[i] = Vwapp05[Refbar] ;
			RefVwapm15[i] = Vwapm15[Refbar] ;
			RefVwapp15[i] = Vwapp15[Refbar] ;
			RefVwapm25[i] = Vwapm25[Refbar] ;
			RefVwapp25[i] = Vwapp25[Refbar] ;
			k++;
		}
	}
	else
	{
			RefVWAP = VWAP;
			RefVwapm1 = Vwapm1;
			RefVwapp1 = Vwapp1 ;
			RefVwapm2 = Vwapm2;
			RefVwapp2 = Vwapp2;
			RefVwapm3 = Vwapm3;
			RefVwapp3 = Vwapp3;

			RefVwapm05 = Vwapm05;
			RefVwapp05 = Vwapp05 ;
			RefVwapm15 = Vwapm15;
			RefVwapp15 = Vwapp15;
			RefVwapm25 = Vwapm25;
			RefVwapp25 = Vwapp25;
	}

	Clrvwap =  ParamColor("Color VWAP",colorGreen) ;
	Clrvwapm1 = ParamColor("Color VWAP -1SD", colorBlueGrey) ;
	Clrvwapp1 = ParamColor("Color VWAP +1SD", colorBlueGrey) ;

	strnday = NumToStr(ndays, 1.0)+"day";

		styleshow = IIf(showvwap, 0, styleNoDraw) ;
//		Vwapstyle = 0 ;
//		if (ndays > 1)
			Vwapstyle = styleNoRescale ;
		Plot(IIf(Lastbar, Null, RefVWAP), "VWAP"+strnday, Clrvwap , styleThick|stylelabel|Vwapstyle|styledata|styleshow, Null, Null, 0, 1);
		if (MAwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 1 ) ;

	Plot(SD, "SD", colorBlack, styleNoDraw|styleNoLabel|styleNoRescale) ;

		styleshow = IIf(showvwap1sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm1), "-1SD"+strnday, Clrvwapm1,  styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp1), "+1SD"+strnday, Clrvwapp1, styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;


		styleshow = IIf(showvwap2sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm2), "-2SD"+strnday, ParamColor("Color VWAP -2SD", colorBlueGrey), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp2), "+2SD"+strnday, ParamColor("Color VWAP +2SD", colorBlueGrey), styleThick  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2+SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), IIf(Lastbar, Null, RefVWAPm2-SD2width), "",ParamColor("Color VWAP -2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		if (SD2width > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2+SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), IIf(Lastbar, Null, RefVWAPp2-SD2width), "",ParamColor("Color VWAP +2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, 0 ) ;

		styleshow = IIf(showvwap3sd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm3), "-3SD"+strnday, ParamColor("Color VWAP -3SD", colorBlueGrey), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp3), "+3SD"+strnday, ParamColor("Color VWAP +3SD", colorBlueGrey), styleThick  + styleNoTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);

		styleshow = IIf(showhalfsd, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, RefVwapm05), "-0.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp05), "+0.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapm15), "-1.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp15), "+1.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapm25), "-2.5SD"+strnday, Clrvwapm1,  styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp25), "+2.5SD"+strnday, Clrvwapp1, styleThick|styleDashed  + styleTitle + stylelabel+styleNoRescale|styledata|styleshow, Null, Null, 0, 1);



		styleshow = IIf(showvwapband, 0, styleNoDraw) ;
		dnclr = ParamColor("Down Trend", colorPink) ;
		upclr = ParamColor("Up Trend", colorSkyblue) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm2), IIf(Lastbar, Null, RefVwapm2), "",ParamColor("Down Trend", colorPink), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp2), IIf(Lastbar, Null, RefVwapp2), "",ParamColor("Up Trend", colorPaleTurquoise), styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		if (showexttrndband)
		{
			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			x0 = BarCount - (trndbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp2) ;
			Ldlast = SelectedValue(RefVwapp1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showexttrndband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", upclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;

			Hdlast = SelectedValue(RefVwapm1) ;
			Ldlast = SelectedValue(RefVwapm2) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;

			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", dnclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,trndbandextend ,extlayer ) ;
		}


		styleshow = IIf(showextvwap, 0, styleNoDraw) ;
		x0 = BarCount - (vwapextend+1)+1 ;
		x1 = BarCount -1 ;

		vwaplast = SelectedValue(RefVWAP) ;
		p1last = SelectedValue(RefVwapp1) ;
		m1last = SelectedValue(RefVwapm1) ;
		p2last = SelectedValue(RefVwapp2) ;
		m2last = SelectedValue(RefVwapm2) ;
showlvls = True ;
		vwapextPlot = LineArray(x0, vwaplast , x1, vwaplast ) ;
		Plot(vwapextPlot , "", Clrvwap, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (MAwidth > 0)
			PlotOHLC(vwapextPlot +MAwidth, vwapextPlot +MAwidth, vwapextPlot -MAwidth, vwapextPlot -MAwidth, "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " 5dvwap"  ;
		if (showlvltext)
			PlotText(NumToStr(vwaplast , 8.1)+str, BarCount+Vwapextend-3, vwaplast , colorBlack) ;

		p1extPlot = LineArray(x0, p1last , x1, p1last ) ;
		Plot(p1extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(p1extPlot +SDwidth , p1extPlot +SDwidth , p1extPlot -SDwidth , p1extPlot -SDwidth , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +1SD5"  ;
		if (showlvltext)
			PlotText(NumToStr(p1last, 8.1)+str, BarCount+Vwapextend-3, p1last , colorBlack) ;

		m1extPlot = LineArray(x0, m1last , x1, m1last ) ;
		Plot(m1extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SDwidth > 0)
			PlotOHLC(m1extPlot +SDwidth , m1extPlot +SDwidth , m1extPlot -SDwidth , m1extPlot -SDwidth , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD5"  ;
		if (showlvltext)
			PlotText(NumToStr(m1last , 8.1)+str, BarCount+Vwapextend-3, m1last , colorBlack) ;

		p2extPlot = LineArray(x0, p2last , x1, p2last ) ;
		Plot(p2extPlot , "", Clrvwapp1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(p2extPlot +SD2width , p2extPlot +SD2width , p2extPlot -SD2width , p2extPlot -SD2width , "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD5"  ;
		if (showlvltext)
			PlotText(NumToStr(p2last , 8.1)+str, BarCount+Vwapextend-3, p2last , colorBlack) ;

		m2extPlot = LineArray(x0, m2last , x1, m2last ) ;
		Plot(m2extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		if (SD2width > 0)
			PlotOHLC(m2extPlot +SD2width , m2extPlot +SD2width , m2extPlot -SD2width , m2extPlot -SD2width , "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, vwapextend, 0 ) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD5"  ;
		if (showlvltext)
			PlotText(NumToStr(m2last , 8.1)+str, BarCount+Vwapextend-3, m2last, colorBlack) ;

		styleshow = IIf(showhalfsd, 0, styleNoDraw) ;
		p05last = SelectedValue(RefVwapp05) ;
		m05last = SelectedValue(RefVwapm05) ;
		p15last = SelectedValue(RefVwapp15) ;
		m15last = SelectedValue(RefVwapm15) ;
		p25last = SelectedValue(RefVwapp25) ;
		m25last = SelectedValue(RefVwapm25) ;

		m05extPlot = LineArray(x0, m05last , x1, m05last ) ;
		Plot(m05extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p05extPlot = LineArray(x0, p05last , x1, p05last ) ;
		Plot(p05extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		m15extPlot = LineArray(x0, m15last , x1, m15last ) ;
		Plot(m15extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p15extPlot = LineArray(x0, p15last , x1, p15last ) ;
		Plot(p15extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		m25extPlot = LineArray(x0, m25last , x1, m25last ) ;
		Plot(m25extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;
		p25extPlot = LineArray(x0, p25last , x1, p25last ) ;
		Plot(p25extPlot , "", Clrvwapm1, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,vwapextend, extlayer) ;

		str = Null ;
		if(showtxtlbl)
			str = " -0.5SD5"  ;
		PlotText(NumToStr(m05last , 8.1)+str, BarCount+Vwapextend-3, m05last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +0.5SD5"  ;
		PlotText(NumToStr(p05last , 8.1)+str, BarCount+Vwapextend-3, p05last , colorBlack) ;

		str = Null ;
		if(showtxtlbl)
			str = " -1.5SD5"  ;
		PlotText(NumToStr(m15last , 8.1)+str, BarCount+Vwapextend-3, m15last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +1.5SD5"  ;
		PlotText(NumToStr(p15last , 8.1)+str, BarCount+Vwapextend-3, p15last , colorBlack) ;

		str = Null ;
		if(showtxtlbl)
			str = " -2.5SD5"  ;
		PlotText(NumToStr(m25last, 8.1)+str, BarCount+Vwapextend-3, m25last , colorBlack) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2.5SD5"  ;
		PlotText(NumToStr(p25last , 8.1)+str, BarCount+Vwapextend-3, p25last , colorBlack) ;

		if (showoncrb)
		{
			Ht = Refh ;
			Lt = Refl ;
			Ct = Refc ;
		}
		else
		{
			Ht = H ;
			Lt = L ;
			Ct = C ;
		}

		Avgp = (Ht+Lt+Ct)/3 ;

	if (showtradearr)
	{

		Buy = Avgp >= Refvwapp1 ;
		Short = Avgp <= Refvwapm1 ;

		Sell =  Avgp <= Refvwapp1 ;
		Cover = Avgp >= Refvwapm1 ;

		Buy = ExRem(Buy, Short OR Sell) ;
		Short = ExRem(Short, Buy OR Cover) ;

		sdp1touch = False ; // Ht >= Refvwapp1 ;
		sdm1touch = False ; //Lt >= Refvwapm1 ;

		Sell = ExRem(Sell, Buy OR sdp1touch ) ;
		Cover = ExRem(Cover, Short OR sdm1touch ) ;

		PlotShapes(Cover*shapeUpArrow, colorViolet, 0, Ht, 12) ;
		PlotShapes(Sell*shapeDownArrow, colorViolet, 0, Lt, 12) ;

		PlotShapes(Buy*shapeUpArrow, colorViolet, 0, Ht, 12) ;
		PlotShapes(Short*shapeDownArrow, colorViolet, 0, Lt, 12) ;

	}

	shift = Param("Shift", 0, -1, 0, 1) ;

	prevdayvalue = prevdayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 1) ;
	prevdayvaluelow = prevdayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 1) ;
	prevdayvaluehigh = prevdayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 1) ;
	prevdayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 1) ;

		styleshow = IIf(showvwapswband, 0, styleNoDraw) ;
		swclr = ParamColor("Sideways Color", colorLavender) ;
		upclr =  ParamColor("Bull Bias Color", colorSkyblue) ;
		dnclr =  ParamColor("Bear Bias Color", colorRose) ;

		if (ndays >= 1)
		{

			bandclr = IIf(Refvwap < prevdayvaluelow, dnclr, IIf(Refvwap > prevdayvaluehigh, upclr, swclr)) ;

			
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), "",bandclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;
			
		if (showextswband)
		{
			styleshow = IIf(showextprevday, 0, styleNoDraw) ;
			x0 = BarCount - (swbandextend +1)+1 ;
			x1 = BarCount -1 ;

			Hdlast = SelectedValue(RefVwapp1) ;
			Ldlast = SelectedValue(RefVwapm1) ;

			Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
//			Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
			LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
//			Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextswband, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", bandclr , styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,swbandextend ,extlayer ) ;

		}


		}
		else
				PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), "",swclr, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;


		if (shift == -1)
		{
			prevdayvaluehigh = prevdayvwap;
			prevdayvalue = prevdayvwapm1 ;
			prevdayvaluelow = prevdayvwapm2 ;
		}

		styleshow = IIf(showprevdayvals, 0, styleNoDraw) ;
		Plot(IIf(Lastbar, Null, prevdayvalue), "Prev VWAP", Clrvwap, styleDots|styleNoRescale+stylelabel|styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluelow), "VAL"+strnday, Clrvwapm1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;
		Plot(IIf(Lastbar, Null, prevdayvaluehigh), "VAH"+strnday, Clrvwapp1, styleDots|styleNoRescale+stylelabel+styleNoTitle|styledata|styleshow) ;

		Clrprevdayband = ParamColor("Prev Day Band Color", colorRose);
			styleshow = IIf(showprevdayband, 0, styleNoDraw) ;
			PlotOHLC(IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluehigh), IIf(Lastbar, Null, prevdayvaluehigh), "",Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale|styledata|styleshow, 0, 0, 0, Vwaplayer ) ;


			styleshow = IIf(showprev2dayvals, 0, styleNoDraw) ;
			prev2dayvalue = prev2dayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 2) ;
			prev2dayvaluelow = prev2dayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 2) ;
			prev2dayvaluehigh = prev2dayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 2) ;
			prev2dayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 2) ;

			Plot(IIf(Lastbar, Null, prev2dayvalue), "2day prev VWAP"+strnday, Clrvwap, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluelow), "2day VAL"+strnday, Clrvwapm1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluehigh), "2day VAH"+strnday, Clrvwapp1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle|styledata|styleshow) ;


		styleshow = IIf(showextprevday, 0, styleNoDraw) ;
		x0 = BarCount - (extend+1)+1 ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(prevdayvaluehigh ) ;
		Ldlast = SelectedValue(prevdayvaluelow ) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "VAHext"+strnday, colorViolet, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "VALext"+strnday, colorViolet, styleLine|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend, extlayer) ;

			styleshow = IIf(showextbandprevday, 0, styleNoDraw) ;
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrprevdayband, styleCloud|styleNoLabel|styleNoTitle|styleNoRescale|styledata|styleshow, 0,0,extend,extlayer ) ;


		showvwaptrend = ParamToggle("Show VWAP Trend", "No|Yes", 0) ;
		styleshow = IIf(showvwaptrend, 0, styleNoDraw) ;
		up = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 >= Ref(RefVwapm1, -1);
		down = RefVwapp1 <= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1) ;
		expand = RefVwapp1 >= Ref(RefVwapp1, -1) AND RefVwapm1 <= Ref(RefVwapm1, -1);


		Clr = IIf(up AND down, colorLavender, IIf(up, colorBlue, IIf(down, colorRed, IIf(expand, IIf(Ct > RefVwap, colorGreen, colorLightOrange), colorLavender)))) ;

		Plot(4, "", Clr, styleArea|styleNoLabel|styleOwnScale|styledata|styleshow, 0, 100,-1) ;


	
	if (showcomm AND NOT nodraw)
	{
		tdayvalue = RefVWAP ;
		tdayvaluehigh = Refvwapp1 ;
		tdayvaluelow = Refvwapm1 ;

		prevdayscore = IIf(Avgp > prevdayvaluehigh, 1,
							IIf(Avgp > prevdayvaluelow, 0,
								-1)) ;

		tdayscore = IIf(Avgp > tdayvaluehigh, 2,
							IIf(Avgp > tdayvalue, 1,
							IIf(Avgp > tdayvaluelow, -1,
								-2))) ;

		totalscore = prevdayscore+tdayscore ;

		switch (SelectedValue(prevdayscore))
		{
			case 1: 
				strprevday = "Above Prev Day Value High " + NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorBlue ;
				break ;
			case 0: 
				strprevday = "In Prev Day Value Range " + NumToStr(SelectedValue(prevdayvaluelow), 1.1) + " - " +  NumToStr(SelectedValue(prevdayvaluehigh), 1.1);
				Clrprevday = colorLavender ;
				break ;			
			case -1: 
				strprevday = "Below Prev Day Value Low " + NumToStr(SelectedValue(prevdayvaluelow), 1.1);
				Clrprevday = colorRed ;
				break ;
		}

		switch (SelectedValue(tdayscore))
		{
			case 2: 
				strtday = "Above Day Value High " + NumToStr(SelectedValue(tdayvaluehigh), 1.1);
				Clrtday = colorBlue ;
				break ;
			case 1: 
				strtday = "Above Day VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorSkyblue ;
				break ;			
			case 0: 
				strtday = "VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorLavender ;
				break ;
			case -1: 
				strtday = "Below Day VWAP " + NumToStr(SelectedValue(tdayvalue), 1.1);
				Clrtday = colorRose ;
				break ;
			case -2: 
				strtday = "Below Day Value Low " + NumToStr(SelectedValue(tdayvaluelow), 1.1);
				Clrtday = colorRed ;
				break ;
		}

	fontsz = Param("Font Size", 14, 0, 1000, 1);
	GfxSelectFont( "Tahoma", fontsz, 100 );
	GfxSetBkMode( 1 );
	pxHeight = Status( "pxchartheight" ) ;
	pxWidth = Status( "pxchartwidth");
	dt_flag = 16 /*wordbreak*/;
	textht = 75;
	textwidth = 150 ;
	x = pxWidth - Param("from right edge", 250, 0, 1000, 1) ;
	y = Param("From Top", 50, 0, 1000, 1) ;

	GfxSetTextColor( Clrprevday );
	GfxDrawText(strprevday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y + textht ;
	GfxSetTextColor( Clrtday );
	GfxDrawText(strtday,  x,y, x+textwidth, y+textht , dt_flag) ;

	y = y ; //+ textht ;
	xbar = x + 150 ;
	Colwidth = 40 ;
	Colht = 75 ;
	tscore = SelectedValue(totalscore) ;

		switch (tscore)
		{
			case 3: 
				strnet = "Strong Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 2: 
				strnet = "Mild Bull" ;
				Clrnet = colorBlue ;
				break ;
			case 1: 
				strnet = "Bull Bias" ;
				Clrnet = colorSkyblue ;
				break ;			
			case 0: 
				strnet = "Neutral" ;
				Clrnet = colorLavender ;
				break ;			
			case -1: 
				strnet = "Bear Bias" ;
				Clrnet = colorRose ;
				break ;
			case -2: 
				strnet = "Mild Bear" ;
				Clrnet = colorRed ;
				break ;
			case -3: 
				strnet = "Strong Bear" ;
				Clrnet = colorRed ;
				break ;
		}

		if (tscore > 0)
		{
			
			GfxSelectSolidBrush(colorBlue) ;
			GfxSelectPen(colorBlue) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*tscore) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*tscore, xbar+Colwidth, y+Colht*3) ;
		}
		else if (tscore == 0)
		{
			
			GfxSelectSolidBrush(colorLavender) ;
			GfxSelectPen(colorLavender) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*3) ;

		}
		else
		{
			
			GfxSelectSolidBrush(colorRed) ;
			GfxSelectPen(colorRed) ;
			GfxRectangle(xbar, y, xbar+Colwidth, y+Colht*abs(tscore)) ;
			GfxSelectSolidBrush(colorLightGrey) ;
			GfxRectangle(xbar, y+Colht*abs(tscore), xbar+Colwidth, y+Colht*3) ;

		}

		y = y + textht ;
		GfxSetTextColor( Clrnet );
		GfxDrawText(strnet,  x,y, x+textwidth, y+textht , dt_flag) ;

	}

	if (showtext AND NOT nodraw AND NOT showlvls)
	{
		str = Null ;
		if(showtxtlbl)
			str = " +1SD5"  ;
		PlotText(NumToStr(RefVwapp1[BarCount-1], 1.1)+str , BarCount+1, RefVwapp1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -1SD5"  ;
		PlotText(NumToStr(RefVwapm1[BarCount-1], 1.1)+str , BarCount+1, RefVwapm1[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " 5dvwap" ;
		PlotText(NumToStr(RefVwap[BarCount-1], 1.1)+str , BarCount+1, RefVwap[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " +2SD5"  ;
		PlotText(NumToStr(RefVwapp2[BarCount-1], 1.1)+str , BarCount+1, RefVwapp2[BarCount-1],Clrtext) ;
		str = Null ;
		if(showtxtlbl)
			str = " -2SD5"  ;
		PlotText(NumToStr(RefVwapm2[BarCount-1], 1.1)+str , BarCount+1, RefVwapm2[BarCount-1],Clrtext) ;

		if (showhalfsd)
		{
			str = Null ;
			if(showtxtlbl)
				str = " +0.5SD5"  ;
			PlotText(NumToStr(RefVwapp05[BarCount-1], 1.1)+str, BarCount+1, RefVwapp05[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -0.5SD5"  ;
			PlotText(NumToStr(RefVwapm05[BarCount-1], 1.1)+str, BarCount+1, RefVwapm05[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " +1.5SD5"  ;
			PlotText(NumToStr(RefVwapp15[BarCount-1], 1.1)+str, BarCount+1, RefVwapp15[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -1.5SD5"  ;
			PlotText(NumToStr(RefVwapm15[BarCount-1], 1.1)+str, BarCount+1, RefVwapm15[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " +2.5SD5"  ;
			PlotText(NumToStr(RefVwapp25[BarCount-1], 1.1)+str, BarCount+1, RefVwapp25[BarCount-1],Clrtext) ;

			str = Null ;
			if(showtxtlbl)
				str = " -2.5SD5"  ;
			PlotText(NumToStr(RefVwapm25[BarCount-1], 1.1)+str, BarCount+1, RefVwapm25[BarCount-1],Clrtext) ;
		}
	}

	if (showvahvaltext AND NOT nodraw)
	{
		str = Null ;
		if(showtxtlbl)
			str = " POC5" ; ;
		PlotText(NumToStr(prevdayvalue[BarCount-1], 1.1)+str, BarCount+1, prevdayvalue[BarCount-1],Clrtext) ;

		str = Null ;
		if(showtxtlbl)
			str = " VAL5" ; ;

		PlotText(NumToStr(prevdayvaluelow[BarCount-1], 1.1)+str, BarCount+1, prevdayvaluelow[BarCount-1],Clrtext) ;

		str = Null ;
		if(showtxtlbl)
			str = " VAH5" ; ;

		PlotText(NumToStr(prevdayvaluehigh[BarCount-1], 1.1)+str, BarCount+1, prevdayvaluehigh[BarCount-1],Clrtext) ;
	}

	scalefactor = 0 ;
	if (scalefactor > 0 AND nDays <= 1)
	{
		Plot(SelectedValue(Ct)+scalefactor*SD, "", colorBlack, styleNoDraw) ;
		Plot(SelectedValue(Ct)-scalefactor*SD, "", colorBlack, styleNoDraw) ;
	}
}
 

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?