>From Tomasz's comments on the StDev function in the user guide: "Note that if you are trying to compare results of StDev function to Excel output you should use STDEVP function in Excel (not StDev)."
http://www.amibroker.com/guide/afl/afl_view.php?id=143 Mike --- In [email protected], "gucytribe" <an...@...> wrote: > > Hi Bill, > > Thanks for the attempt, however the results don't much Excel (the Standard > dev is a little over half of what it should be). Since Etoke is working on > the same thing I will add my comments into his thread. > > Tip2012 > > --- In [email protected], Bill S <wjs45244@> wrote: > > > > I haven't checked the accuracy you can try this: > > Avgvol=0; > > sd = 0; > > if (Interval()<inDaily) > > { > > n = round(3600*6.75/Interval()); //number of bars in the day > > d = Param("Lookback days",5,1,30,1); //averaging period > > barnum = BarsSince(Day()!=Ref(Day(),-1)); //bar number from start of the > > day > > for (i=0; i<n; i++) > > { > > VarSet("vol"+i,IIf(i==barnum,V,0)); > > } > > for (i=0; i<n; i++) > > { > > Avgvol=IIf(barnum==i,Sum(VarGet("vol"+i),n*d)/d,Avgvol); > > sd = IIf( barnum==i, StDev( VarGet( "vol"+i), n*d), sd); > > } > > Plot( Avgvol, "Average Volume:" + d + " days", colorWhite, styleLine ); > > Plot( Avgvol+sd, "1 std dev:", colorBrown, styleLine); > > } > > > > > > > > > > On Fri, May 1, 2009 at 11:17 AM, gucytribe <angus@> wrote: > > > > > > > > > > > Hi, > > > > > > I downloaded this code from the Amibroker AFL library which calculates the > > > intraday average volume. I have been trying to calculate the standard > > > deviation of volume for the same time of day, however after messing around > > > with it for quite some time I still haven't managed to code anything that > > > gives the correct answer. > > > > > > Can someone please help? > > > > > > Many thanks. > > > > > > Avgvol=0; > > > if (Interval()<inDaily) { > > > n = round(3600*6.75/Interval()); //number of bars in the day > > > d = Param("Lookback days",5,1,30,1); //averaging period > > > barnum = BarsSince(Day()!=Ref(Day(),-1)); //bar number from start of the > > > day > > > for (i=0; i<n; i++) { > > > VarSet("vol"+i,IIf(i==barnum,V,0)); > > > } > > > for (i=0; i<n; i++) { > > > Avgvol=IIf(barnum==i,Sum(VarGet("vol"+i),n*d)/d,Avgvol); > > > } > > > > > > } > > > > > > > > > > > >
