correct the afl

muinali

Well-Known Member
#1
masters
plz correct the afl .why does this afl not showing standard deviation curve


_SECTION_BEGIN("VWAP_SD1");
starttime = 153000;
endtime = 230000;

timeWindow = TimeNum() >= starttime AND TimeNum() <= endtime;
firstBarOfDay = TimeNum() >= starttime ;
firstBarOfDay = firstBarOfDay - Ref(firstBarOfDay,-1);

P = (H + L)/2;

vv = V * P * timeWindow;

BarsInDay = (1 + BarsSince(firstBarOfDay)) * timeWindow;
CumVolumeInDay = Sum(V,BarsInDay);
VWAP = Sum(vv, BarsInDay ) / CumVolumeInDay;
SV = Sum((P - VWAP)^2,BarsInDay) / BarsInDay; // sample variance
SD = sqrt(SV); // standard deviation

// chart
SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
SetChartOptions(0, chartShowDates);
Plot(C,"\nClose",colorWhite,64);
Plot(IIf(VWAP,VWAP,Null),"\nVWAP",ParamColor("ColorVWAP",ColorRGB(255,20,147)),styleThick);
Plot(IIf(VWAP,VWAP + SD,Null), "\n+1SD", ParamColor("ColorSDP",ColorRGB(238,174,238)),styleDashed);
Plot(IIf(VWAP,VWAP - SD,Null), "\n-1SD", ParamColor("ColorSDM",ColorRGB(210,180,140)),styleDashed);
Plot(IIf(VWAP,VWAP + 2*SD,Null), "\n+2SD", ParamColor("ColorSDPP",ColorRGB(153,102,204)),styleDashed);
Plot(IIf(VWAP,VWAP - 2*SD,Null), "\n-2SD", ParamColor("ColorSDMM",ColorRGB(238,154,73)),styleDashed);
Plot(IIf(VWAP,VWAP + 3*SD,Null), "\n+3SD", ParamColor("ColorSDPPP",ColorRGB(128,0,128)),styleDashed);
Plot(IIf(VWAP,VWAP - 3*SD,Null), "\n-3SD", ParamColor("ColorSDMMM",ColorRGB(238,118,33)),styleDashed);
Plot(timeWindow, "",ParamColor("ColorBK",ColorRGB(20,20,20)), styleArea|styleOwnScale,0,1);
_SECTION_END();
 

hitesh

Active Member
#3
I think you need to change starttime and endtime. (if trading indian stock market)


_SECTION_BEGIN("VWAP_SD1");
starttime = 093000;
endtime = 153000;

//starttime = 153000;
//endtime = 230000;

timeWindow = TimeNum() >= starttime AND TimeNum() <= endtime;
firstBarOfDay = TimeNum() >= starttime ;
firstBarOfDay = firstBarOfDay - Ref(firstBarOfDay,-1);

P = (H + L)/2;

vv = V * P * timeWindow;

BarsInDay = (1 + BarsSince(firstBarOfDay)) * timeWindow;
CumVolumeInDay = Sum(V,BarsInDay);
VWAP = Sum(vv, BarsInDay ) / CumVolumeInDay;
SV = Sum((P - VWAP)^2,BarsInDay) / BarsInDay; // sample variance
SD = sqrt(SV); // standard deviation

// chart
SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
SetChartOptions(0, chartShowDates);
Plot(C,"\nClose",colorWhite,64);
Plot(IIf(VWAP,VWAP,Null),"\nVWAP",ParamColor("Colo rVWAP",ColorRGB(255,20,147)),styleThick);
Plot(IIf(VWAP,VWAP + SD,Null), "\n+1SD", ParamColor("ColorSDP",ColorRGB(238,174,238)),styleDashed);
Plot(IIf(VWAP,VWAP - SD,Null), "\n-1SD", ParamColor("ColorSDM",ColorRGB(210,180,140)),styleDashed);
Plot(IIf(VWAP,VWAP + 2*SD,Null), "\n+2SD", ParamColor("ColorSDPP",ColorRGB(153,102,204)),styleDashed);
Plot(IIf(VWAP,VWAP - 2*SD,Null), "\n-2SD", ParamColor("ColorSDMM",ColorRGB(238,154,73)),styleDashed);
Plot(IIf(VWAP,VWAP + 3*SD,Null), "\n+3SD", ParamColor("ColorSDPPP",ColorRGB(128,0,128)),styleDashed);
Plot(IIf(VWAP,VWAP - 3*SD,Null), "\n-3SD", ParamColor("ColorSDMMM",ColorRGB(238,118,33)),styleDashed);
Plot(timeWindow, "",ParamColor("ColorBK",ColorRGB(20,20,20)), styleArea|styleOwnScale,0,1);
_SECTION_END();
 

muinali

Well-Known Member
#5
-----------------------------
 

muinali

Well-Known Member
#6
-----------------------
 
Last edited:

Similar threads