[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Standard deviation of Intraday average volume



PureBytes Links

Trading Reference Links



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@xxxxxxxxxxxxx> 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);
}

}





__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___