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

Re: [amibroker] Coding Question



PureBytes Links

Trading Reference Links

Dean,
I think the program below does what you want to do.  It compares the  
volume today with the average volume at the same time of day for the past  
7 days.


TradeDate1	=	1041116;	// trade date 1 day ago
TradeDate2	=	1041115;	// trade date 2 days ago
TradeDate3	=	1041112;	// trade date 3 days ago
TradeDate4	=	1041111;	// trade date 4 days ago
TradeDate5	=	1041110;	// trade date 5 days ago
TradeDate6	=	1041109;	// trade date 6 days ago
TradeDate7	=	1041108;	// trade date 7 days ago
TradeDate8	=	1041105;	// trade date 8 days ago

x1 = BarsSince(DateNum()==TradeDate1);	
x2 = BarsSince(DateNum()==TradeDate2);
x3 = BarsSince(DateNum()==TradeDate3);
x4 = BarsSince(DateNum()==TradeDate4);
x5 = BarsSince(DateNum()==TradeDate5);
x6 = BarsSince(DateNum()==TradeDate6);
x7 = BarsSince(DateNum()==TradeDate7);
x8 = BarsSince(DateNum()==TradeDate8);

CumVol1 = Sum(V,x1);				// cum vol today
CumVol2 = Sum(V,x2)-Sum(V,x2-x1);		// cum vol 1 day
CumVol3 = Sum(V,x3)-Sum(V,x3-x1);		// cum vol 2 days
CumVol4 = Sum(V,x4)-Sum(V,x4-x1);		// cum vol 3 days
CumVol5 = Sum(V,x5)-Sum(V,x5-x1);		// cum vol 4 days
CumVol6 = Sum(V,x6)-Sum(V,x6-x1);		// cum vol 5 days
CumVol7 = Sum(V,x7)-Sum(V,x7-x1);		// cum vol 6 days
CumVol8 = Sum(V,x8)-Sum(V,x8-x1);		// cum vol 7 days

V0 = CumVol1-Ref(CumVol1,-1);			// vol today
V1 = CumVol2-Ref(CumVol2,-1);			// vol 1 day ago
V2 = CumVol3-Ref(CumVol3,-1);			// vol 2 days ago
V3 = CumVol4-Ref(CumVol4,-1);			// vol 3 days ago
V4 = CumVol5-Ref(CumVol5,-1);			// vol 4 days ago
V5 = CumVol6-Ref(CumVol6,-1);			// vol 5 days ago
V6 = CumVol7-Ref(CumVol7,-1);			// vol 6 days ago
V7 = CumVol8-Ref(CumVol8,-1);			// vol 7 days ago

AvgVol = (V1+V2+V3+V4+V5+V6+V7)/7;		// 7 Day Average
diff = v0 - AvgVol;

Filter = DateNum()==Now(3);
AddColumn(O," Open  ",1.2);
AddColumn(H," High  ",1.2);
AddColumn(L,"  Low  ",1.2);
AddColumn(C," Close  ",1.2);
AddColumn(v0,"    Today   ",1.0);
AddColumn(Avgvol,"   Average   ",1.0);
AddColumn(diff,"Difference", 1.0 , IIf( diff < 0, colorRed, colorDefault),  
colorDefault );
AddColumn( Cum(diff),"Cumulative", 1.0 , IIf( Cum(diff) < 0, colorRed,  
colorDefault), colorDefault );

Buy=Sell=Short=Cover=0;

Bill S.











On Wed, 17 Nov 2004 20:48:42 -0000, Dean Hodgins <deanhodgins@xxxxxxxxx>  
wrote:

>
>
> I'm wondering if anyone has any code that would filter/scan the
> cummulative volume for the current day versus the average cummulative
> volume for the day but only to the same point as today's volume.
>
> For example if I'm using 15 min bars and I'm 4 bars into the current
> day I'd like to compare that volume with the "normal" (say 10 day
> average) volume 4 bars into the current day.
>
> The problem or issue here is that the formula would have to be
> dynamic in the sense that it compares/calculates only volume to a
> certain point in the trading day which changes each time a new scan
> is run assuming that new bars have elapsed.
>
> As always - any ideas most apprecaited.
>
>
> Thanks & Regards,
>
>
> Dean Hodgins
>
>
>
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at:  
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> Yahoo! Groups Links
>
>
>
>
>
>




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/