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

Reply
Old 12-13-2009, 05:12 AM   #1

Join Date: Dec 2009
Location: Barreiro
Posts: 10
Ignore this user

Thanks: 8
Thanked 1 Time in 1 Post

Help with Formula

Hello.

I'm having trouble with a study, and I would like some help with it.

The premise is simple.
Recording today's total volume traded between a specified time range and comparing it with the same previous day traded volume during the same specified time range.

So far so good. The formula below does just that.

The thing is, I want today's reading to indicate the difference of traded volume when compared to yesterday's traded volume at that same time.

So, if today, at 10:05 AM, the ES has already traded 115.882 futures, what is the difference in %, when compared to yesterday's same time?
I can say that this Friday, at 10:05 AM we had traded 129% more volume than the previous day at that same time.

Simply said, I want to know in realtime the trade volume difference when compared to yesterday's traded volume?
How can I program and insert that in the formula below?

Thank you.

Regards,
Fernando

PS: I use Multicharts.

Code:
Inputs: 
   startTime      (930), 
   endTime      (1200); 

variables: 
   stTime         (false), 
   resetVol      (false), 
   sessVol      (0), 
   myVolume      (0), 
   prevVolume      (0), 
   todayVolume      (0); 


if BarType >= 2 then                              
   MyVolume = Volume 
else                        
   MyVolume = Ticks; 
    
    
if date <> date[1] then begin 
   resetVol = false; 

   if time > startTime and resetVol = false then begin 
      resetVol = true; 
      prevVolume = todayVolume; 
      todayVolume = 0; 
   end; 

end; 

if time > startTime and time < endTime then begin 
   todayVolume = todayVolume + myVolume; 
end; 


plot1(todayVolume); 
plot2(prevVolume);
arnie_pt is offline  
Reply With Quote
Old 12-13-2009, 08:27 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 with Formula

Quote:
Originally Posted by arnie_pt »
...
So, if today, at 10:05 AM, the ES has already traded 115.882 futures, what is the difference in %, when compared to yesterday's same time?
I can say that this Friday, at 10:05 AM we had traded 129% more volume than the previous day at that same time.
...

What is your chart resolution?

are you looking at volume at each 5 min block?
or volume since the market opening?
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 12-13-2009, 12:09 PM   #3

Join Date: Dec 2009
Location: Barreiro
Posts: 10
Ignore this user

Thanks: 8
Thanked 1 Time in 1 Post

Re: Help with Formula

Quote:
Originally Posted by Tams »
What is your chart resolution?

are you looking at volume at each 5 min block?
or volume since the market opening?
Hi.

I'm looking at volume since the opening, in this case, since startTime input.

Plotting todayVolume variable we'll have the volume reading/accumulation since the startTime input until the endTime input.
The formula should be able to read resolutions above 1 minute. The attached chart shows the indicator plotted in an ES 1 minute chart.

We already have access to the previous day's volume with the prevVolume variable. The thing is how to have access to the volume reading/accumulation time of yesterday so we can compare it with the same time in today's volume reading/accumulation?

Basically, what I want, based on the time range sellected in the inputs, is to be able to see in realtime, 1 minute, 5 minutes or 30 minutes charts, the volume difference at that precise time when comparing it with yesterday's same time.

Thank you.
Attached Thumbnails
Help with Formula-es_snapshot8.png  
arnie_pt is offline  
Reply With Quote
Old 12-13-2009, 12:29 PM   #4

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 with Formula

you can create a counter to count the bars,
so that you can reference it later.


Attached Thumbnails
Help with Formula-bar.jpg  
__________________



Only an idiot would reply to a stupid post

Last edited by Tams; 12-13-2009 at 12:49 PM.
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
TIKITRADER (12-19-2009)
Old 12-13-2009, 04:14 PM   #5

Join Date: Dec 2009
Location: Barreiro
Posts: 10
Ignore this user

Thanks: 8
Thanked 1 Time in 1 Post

Re: Help with Formula

Quote:
Originally Posted by Tams »
you can create a counter to count the bars,
so that you can reference it later.
Hi.

It seems that I need to use for loop (?) (based on your image), but unfortunately my EL knowledge is still very limited and I haven't yet understood how that works

I've tried something like, for counter = 1 to current bar begin, but naturally I've got no where

I created the counter and changed slightly the formula since the previous version had a problem.

I've also created the volPCT variable to calculate the % from yesterday, just to see the result of it, and at first I received an zero division error.
I added the maxlist function which resolved the problem, but I don't know if this is the best option.

Code:
Inputs:
	startTime		(1200),
	endTime		(1400);

variables:
	stTime			(false),
	resetVol		(false),
	sessVol		(0),
	myVolume		(0),
	prevVolume		(0),
	todayVolume		(0),
	counter		(0),
	volPct			(0);

if BarType >= 2 then                             
	MyVolume = Volume
else                        
	MyVolume = Ticks;
	
if date <> date[1] then begin
	counter = 0;
	prevVolume = todayVolume;
	todayVolume = 0;
end
else begin
	if time > startTime and time < endTime then begin
		todayVolume = todayVolume + myVolume;
		counter = counter + 1;
	end;
end;


//volPct = ((todayVolume/maxlist(prevVolume,0.01)) - 1) * 100;
	

plot1(todayVolume);
plot2(prevVolume);
//plot3(counter);
//plot4(volPct);
arnie_pt is offline  
Reply With Quote
Old 12-13-2009, 04:36 PM   #6

Join Date: May 2009
Location: Dallas
Posts: 93
Ignore this user

Thanks: 52
Thanked 136 Times in 56 Posts

Re: Help with Formula

On time bars, I've always found it easiest (though not the most memory-efficient method) to make an array sized 2400 and fill it/look it up based on time[0].

So basically the code has a structure like this:

Code:
arrays:
  double volarray[2400](0);

// look up yesterdays...
// remember easylanguage arrays are 1-based indexes
// so to be correct you'd add 1 
value1 = volarray[time+1];

// do something with it
plot1(volume - value1,"voldiff");

// store today's...
volarray[time+1] = volume;
RichardTodd is offline  
Reply With Quote
The Following User Says Thank You to RichardTodd For This Useful Post:
Tams (12-13-2009)
Old 12-13-2009, 04:42 PM   #7

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 with Formula

Quote:
Originally Posted by RichardTodd »
On time bars, I've always found it easiest (though not the most memory-efficient method) to make an array sized 2400 and fill it/look it up based on time[0]. ...

Array would be easiest method...
that is, if you have overcame the Array hurdle. ;-)>

here's some array help
http://www.traderslaboratory.com/for...uage-5785.html
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 12-13-2009, 07:36 PM   #8

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 with Formula

Quote:
Originally Posted by arnie_pt »
Hi.

It seems that I need to use for loop (?) (based on your image), but unfortunately my EL knowledge is still very limited and I haven't yet understood how that works

I've tried something like, for counter = 1 to current bar begin, but naturally I've got no where

I created the counter and changed slightly the formula since the previous version had a problem.

I've also created the volPCT variable to calculate the % from yesterday, just to see the result of it, and at first I received an zero division error.
I added the maxlist function which resolved the problem, but I don't know if this is the best option....


don't jump into coding yet... you are a long way from ready.

1. Loops is easy... it is not rocket science...you just need to read the manual.

2. The problem at hand is NOT about programming in EasyLanugage...

The problem is: how do you think through your logic:

i.e. writing out your thoughts...

a. describe what you want to do... and
b .describe HOW you are going about to get want you want.
c. the first set step in getting what you want is to give the computer what it needs...

can you list out the items the computer need in order to do your calculation?



hint: you don't need a loop, and I am not talking about array,
and your description so far is incomplete...
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote

Reply

Tags
price volume relationship, volume

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
Tony Crabel's Opening Range Formula Soultrader E-mini Futures Trading Laboratory 17 01-29-2010 12:18 PM
Help Needed Converting Easy Language Formula Danaty Coding Forum 0 11-21-2008 06:10 PM
Please Help with ESignal Indicator/Formula - Price Pivots tradinghumble Technical Analysis 0 09-04-2008 10:41 PM
Mark Fishers AC Stock Formula for All. Szymon Technical Analysis 2 04-19-2008 06:11 AM

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