Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 02-28-2009, 12:37 AM   #1

Join Date: Dec 2008
Location: SoCal
Posts: 8
Ignore this user

Thanks: 4
Thanked 1 Time in 1 Post

Help W/ Avg Vol By TimeFrame ELD

I found the following code on tradestation forums. It's supposed to show the average volume and median volume by timeframe for a specified number of days back. However, the results don't line up with my calculations so I figured I would see if some experiences coders in here could have a look and see what's wrong. Here's the code:



INPUTS: Days.Back( 5) ;

VARIABLES: Days.Count( 0 ),
Session.Minutes( 0 ),
Total.Volume( 0 ),
Volume.Average( 0 ),
Volume.Median( 0 ),
Counter( 0 ),
Bars.per.Day( 0 ) ;


IF BarType = 1 THEN BEGIN { plot intraday time charts only }

Session.Minutes = TimeToMinutes(1515) - TimeToMinutes(0830) ;

Bars.per.Day = Round( ( Session.Minutes/BarInterval )+ 0.49, 0 ) ; { round-up }

//print(Counter);
//print(barnumber);
//Print("*******");

Total.Volume = 0 ;
Days.Count = 0 ;

FOR Counter = Round( BarInterval * 0.5, 0 ) TO Days.Back * Bars.per.Day BEGIN

IF Time = Time[Counter] AND
Days.Count < Days.Back THEN BEGIN
Total.Volume = Total.Volume + UpTicks[Counter] + DownTicks[Counter] ;
Days.Count = Days.Count + 1 ;
END ;

END ;
if Days.Count <> 0 then
Volume.Average = Total.Volume/Days.Count ;

Volume.Median = median(Upticks + Downticks,Days.Count);

Plot1( Volume.Median, "Median Vol" ) ;

Plot2( Volume.Average, "AvgVol(ToD)" ) ;

Plot3( UpTicks + DownTicks, "Volume" ) ;
if upticks > downticks then
setplotcolor(3,green);
If plot3 > Plot1 and plot3 > Plot2 then Alert("High Volume");

END ;
CuriousGeorge is offline  
Reply With Quote
Old 04-05-2009, 12:03 AM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Help W/ Avg Vol By TimeFrame ELD

Quote:
Originally Posted by CuriousGeorge »
I found the following code on tradestation forums. It's supposed to show the average volume and median volume by timeframe for a specified number of days back. However, the results don't line up with my calculations...


what instrument and what time frame is your chart?
what is it off by?
Tams is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access Higher Timeframe Data thewoj Coding Forum 3 02-29-2008 12:36 AM
How vital is the timeframe that you pick for your charts? brownsfan019 Technical Analysis 29 11-22-2007 06:49 PM

All times are GMT -4. The time now is 12:36 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.