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

Like Tree1Likes

Reply
Old 10-31-2009, 04:08 PM   #1

Join Date: Oct 2009
Location: Catania
Posts: 20
Ignore this user

Thanks: 2
Thanked 3 Times in 1 Post



Building a VolumeProfile Indicator with EasyLanguage

Hi,
reading here and there posts in the forum, from coding forum to trading indicators to array ecc... I've never found a code about Volume Profile.
Many codes about Market Profile (TPO) , market delta and something about Peak of Volume at Price (PVP) which is called "mode" in statistic language, but nothing about a good Volume profile accurate to the tick.
I've read posts from TAMS about ARRAY (very good and useful), code from DBantina about PVP (MODE) using tick chart, which could be a very good beginning, but nothing again about the Volume profile, so I've decided to create a new one searching someone who could help me.
This is my start and my steps:
(1)
I've a GKMarketProfileTL (see txt attached files) which uses trend lines, but it's a proxy and not accurate to the tick because it uses minutes chart (1 minute chart in the best way).

This indicator is not so useful because with trendlines, it's difficult to plot a volume profile for each day. Trend lines could be useful to plot a single Volume profile for the last day or for a cumulative profile made of more than one day. Then it's not so accurate (not to the tick ).

(2)
I've a second indicator which plots TPO MarketProfile (see txt attached below with its functions) which uses ASCII scripts as I'd like, but it calculates TPO and not Volume Profile. I've modified it to plot NOT only letters (put in inputs letters = false), but even ASCII scripts like "---".


The problem with this indicator is that it's very difficult to decode and modify for my experience. Maybe its functions are useful to plot ascii scripts instead of Trendlines.

So, watching these codes I'd like to create a Volume Profile code (indicator) which plots an histogram for each single day (session) using ASCII scripts instead of trendlines.
It should be accurate to the tick, so I MUST calculate it on a tick chart.
Doing this, I've copied a DBantina logic (code):
on a 1 tick chart based on Trade Volume, calculate a range of each day and reset it each day.
STEP ONE:
//I've made a counter for each tick of the chart reset each day
if date > Date[1] then begin
MyOpen = open;
MyHigh = High;
MyLow = low;
MyClose = close;
counter = 1;
end;

If Date = date[1] then begin

If high > MyHigh then
MyHigh = High;
If Low < MyLow then
MyLow = Low;
if time >= Sess1endtime then
MyClose = close;
If time < Sess1endtime and lastbaronchart then
MyClose = close;
counter = counter + 1;
end;

RangeDay = MyHigh - MyLow;


STEP TWO
Then I have to identify the lines for each day for each Volume profile Histogram:

TickScale = minmove/priceScale;
NLines = RangeDay /TickScale;

STEP Three
Now I've to create an ARRAY (dinamic) to identify the volume for each line of the histogram.
I Think that this is correct.

MyVol = iff(bartype < 2, Upticks + Downticks, volume);
Array: HISTO[](0);

if date > date[1] then begin
Array_SetMaxIndex(Histo, NLines); // resize the array each day
HISTO[iPrice] = 0; // rest to zero each day
TotalVolume = 0;
END;

STEP FOUR
Now I've to populate the array with volume for each line level on each tick (1 tick chart).
for iPrice = 0 to NLines
begin
Histo[iPrice] = 0;
end;
for jBar = 0 to (counter-1)
begin
jLow = (L[jBar] - MyLow)/TickScale);
jHigh = (H[jBar] - MyLow)/TickScale);
if ((jHigh - jLow) > 0) then begin
deltaVol = MyVol[jBar]/(jHigh - jLow);
for iPrice = jLow to jHigh
begin
Histo[iPrice] = Histo[iPrice] + deltaVol;
TotalVolume = TotalVolume + deltaVol;
end;
end;

NOW if my thoughts are correct, the array Histo[iPrice] should be the Volume profile data and I've to Plot them using a way that permit me to plot ASCII scripts as in the TPO indicator.

AM I correct ???
Could someone give me an help to coding Volume Profile
At this point I don't know how to go on

THANKS
AndyTick
Attached Files
File Type: txt GKMarketProfile TL.txt (16.3 KB, 145 views)
File Type: txt TPO Pro5.0b.txt (7.7 KB, 143 views)
File Type: txt nutpstr (function - numeric).txt (311 Bytes, 84 views)
File Type: txt curletstr_AL (function - numeric).txt (1.1 KB, 80 views)
File Type: txt curletstr (function - numeric).txt (1.1 KB, 85 views)
Andytick is offline  
Reply With Quote
The Following 3 Users Say Thank You to Andytick For This Useful Post:
agon (11-26-2009), EasyTrader_I (01-04-2011), Tams (10-31-2009)
Old 10-31-2009, 05:08 PM   #2

Tams's Avatar

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

Thanks: 2,027
Thanked 1,402 Times in 862 Posts



Re: Building a VolumeProfile Indicator with EasyLanguage

are you and Crazynasdaq the same person?
__________________


..........This is a terribly difficult question to answer. The only satisfactory answer is: "It depends"...
Tams is offline  
Reply With Quote
Old 10-31-2009, 08:24 PM   #3

Join Date: Oct 2009
Location: Catania
Posts: 20
Ignore this user

Thanks: 2
Thanked 3 Times in 1 Post



Re: Building a VolumeProfile Indicator with EasyLanguage

Quote:
Originally Posted by Tams »
are you and Crazynasdaq the same person?
No.
Maybe you spoke about crazynasdaq for the post about ARRAY from which I've taken some stuff and ideas for my code, but I'm not the person You wrote about.
Andytick is offline  
Reply With Quote
Old 10-31-2009, 09:19 PM   #4

Tams's Avatar

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

Thanks: 2,027
Thanked 1,402 Times in 862 Posts



Re: Building a VolumeProfile Indicator with EasyLanguage

here are my note:

1. pls wrap codes in code tags. the code tag is the # key at the top of the reply window

2. don't be so cheap with variables -- make the name more explicit. It doesn't cost anything, but will make debugging easier. e.g. I can't tell what jLow is.

3. you need to write out your logical operation in finer resolution.
you were doing well... until step 4.
Step 4 is the most involved -- you have loops and assignments and matchings...
you need to break down step 4 into more coherent thoughts.
Draw a flow chart... with lines and arrows illustrating data flow

try this too... plot out exactly which data goes into which slot:




4. put PRINT statements before and after every variable assignment...
this is the best way to track the data flow
see here for more information on print.
http://www.traderslaboratory.com/for...uage-6000.html


have fun...
__________________


..........This is a terribly difficult question to answer. The only satisfactory answer is: "It depends"...

Last edited by Tams; 10-31-2009 at 09:27 PM.
Tams is offline  
Reply With Quote
Old 11-01-2009, 02:33 PM   #5

Join Date: Oct 2009
Location: Catania
Posts: 20
Ignore this user

Thanks: 2
Thanked 3 Times in 1 Post



Re: Building a VolumeProfile Indicator with EasyLanguage

Ok TAMS, I'll be more clear in my posts.
Now I've a Big question in my mind.

I need a 1 dimensional array or a 2 dimensional array made of 2 columns and N lines ?



I ASK an help on this because the logic tells me that I need a 2 dimensional array as showed in the image, but the DBntina code about PVP (calculate the mode and the volume of the mode ) uses a 1 dimensional array to calculate Volume and level price of the mode. http://www.traderslaboratory.com/for...html#post32650
Look at the code:

Code:
   
vars:         MyVolume(0),
		PriceDiff(0),
		StartPrice(0),
		PVPPrice(0),
		PVPVolume(0),
		V2VolLevel(0);	

	Array:
		PVPVolArray[10000] (0);
	
	MyVolume = Volume;
		
	if date > date[1] then begin
		StartPrice = AvgPrice;
		For Value1 = 0 to 10000 Begin
			PVPVolArray[Value1] = 0;
		End;
		PVPVolArray[5000] = MyVolume;
		PVPPrice = AvgPrice;
		PVPVolume = MyVolume;
	end;

	If date = date[1] And StartPrice > 0 Then Begin
		Value2 = AvgPrice - StartPrice;
		V2VolLevel = 5000+(Value2*(1/(minmove/pricescale)));
		PVPVolArray[V2VolLevel] = PVPVolArray[V2VolLevel] + MyVolume;
	
		If PVPVolArray[V2VolLevel] > PVPVolume Then Begin
			PVPVolume = PVPVolArray[V2VolLevel];
			PriceDiff = 5000-V2VolLevel;
			PVPPrice = StartPrice - (PriceDiff*(minmove/pricescale));
		End;

	End;

	Plot1(PVPPrice, "PVP");
	Plot2(PVPVolume, "PVPVolume"); 

END;
This code calculate the PVPVolume (numbers of contracts/shares) and the PVPPrice (level of price with the biggest Volume). So, its' possible to calculate Volume at price with a single dimensional array. He simply calculates one level price and the volume of that single price.
It uses a single dimensional array, but the logic behind it is not so clear to me.
Could someone help me to understand the logic behind ? Here are my dubts:
1 - he declare an array with a max dimension of 10000, but when he start to calculate, he splits the dimension from 10000 to 5000 and equal the array to Volume. Why ?
Code:
Array:  PVPVolArray[10000] (0);
	
	MyVolume = Volume;

if date > date[1] then begin
		StartPrice = AvgPrice;
		For Value1 = 0 to 10000 Begin
			PVPVolArray[Value1] = 0;     // OK !! He reset each day the array
		End;

		PVPVolArray[5000] = MyVolume;   // Why splits the array dimension ?
		PVPPrice = AvgPrice;
		PVPVolume = MyVolume;
	end;


Now he populates the array and identifies the V2VolLevel for each price of the day, but always from half the dimension of the inital array dimension. Why half the dimension again ?
Code:
If date = date[1] And StartPrice > 0 Then Begin
		Value2 = AvgPrice - StartPrice;
		V2VolLevel = 5000+(Value2*(1/(minmove/pricescale)));
		PVPVolArray[V2VolLevel] = PVPVolArray[V2VolLevel] + MyVolume;
END;
Now my question at this point is:
Is the PVPVolArray[V2VolLevel] the array which contains all the volume at price Volumes ?
Or it's the array which contains ONLY the PVP Volume ?
Using this logic, is it possible to loop it to calculate the Volume at price for each single level of the day's range price ?
I ask this, because it seems to me that this logic is the most accurate and less CPU intensive to calculate, and then the code seems quicker and easier once you have understand the logic behind (not me now !!! )

PLEASE, could someone help me to understand

Then last step he identifies the volume level price and constrains the PVPVolume, always using half the intial dimension
Code:
If PVPVolArray[V2VolLevel] > PVPVolume Then Begin
			PVPVolume = PVPVolArray[V2VolLevel];
			PriceDiff = 5000-V2VolLevel;
			PVPPrice = StartPrice - (PriceDiff*(minmove/pricescale));
END;
AndyTick
Andytick is offline  
Reply With Quote
Old 11-01-2009, 05:44 PM   #6

Join Date: Nov 2009
Location: new york
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts



Re: Building a VolumeProfile Indicator with EasyLanguage

Andytick and/or Crazynasdaq
you are a criminal CRACKER!


The TPO Pro5.0b.txt indicator is a commercial
indicator: you have stolen the work of others !
(see password in the code)

Tams
and all the honest persons in this forum
be careful with these lawbreakers.
brownmar is offline  
Reply With Quote
Old 11-01-2009, 06:04 PM   #7

Tams's Avatar

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

Thanks: 2,027
Thanked 1,402 Times in 862 Posts



Re: Building a VolumeProfile Indicator with EasyLanguage

Quote:
Originally Posted by Andytick »
Ok TAMS, I'll be more clear in my posts.
Now I've a Big question in my mind.

I need a 1 dimensional array or a 2 dimensional array made of 2 columns and N lines ?

I ASK an help on this because the logic tells me that I need a 2 dimensional array as showed in the image, but the DBntina code about PVP (calculate the mode and the volume of the mode ) uses a 1 dimensional array to calculate Volume and level price of the mode...

I believe DBntina uses the mid point of the array as starting point...

1. he can save one dimension in the array... because array takes up memory !
2. faster operation
3. opening tick is the starting point... all subsequent ticks are as a plus or minus of the previous tick... therefore no need for the price data.


CLEVER !
__________________


..........This is a terribly difficult question to answer. The only satisfactory answer is: "It depends"...

Last edited by Tams; 11-01-2009 at 06:14 PM.
Tams is offline  
Reply With Quote
Old 11-01-2009, 06:29 PM   #8

Join Date: Oct 2009
Location: Catania
Posts: 20
Ignore this user

Thanks: 2
Thanked 3 Times in 1 Post



Re: Building a VolumeProfile Indicator with EasyLanguage

Quote:
Originally Posted by brownmar »
Andytick and/or Crazynasdaq
you are a criminal CRACKER!


The TPO Pro5.0b.txt indicator is a commercial
indicator: you have stolen the work of others !
(see password in the code)

Tams
and all the honest persons in this forum
be careful with these lawbreakers.
Brownmar,
I'm not a CRIMINAL CRACKER as you say......
if I was the person able to crack a code, you think that I would need an help coding an indicator like Volume profile ?
I've found it on the web in a forum like this as many others have done before me and will do after me. I didn't know that it was a commercial code. Simply I downloaded it when I found it.
If you are so clever to understand that I'm a "CRIMINAL CRACKER" without knowing me at all, try to use google and search "MARKET PROFILE TPO"...........after some first links, you will find this Forums - Free Market Profile for Tradestation.
This is the web and if I find a useful stuff without doing anything illegal in searching it, I don't think to be a CRIMINAL, so be quiet with some words and use your brain in a more clever way instead of insult people you don't know at all.
Google could be a great thing for someone and a very bad thing for others, don't forget it !!!
Maybe you have to use a different tone and different words speaking about people you don't know at all, like me.
And an other time..........I don't know who crazynasdaq is, but I'm not him or her, whoever he/she is.

Last edited by Andytick; 11-01-2009 at 06:45 PM.
Andytick is offline  
Reply With Quote

Reply

Tags
array, volume

« Snake Force | - »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
EasyLanguage Indicator -- How Long (in Min) 1500 Tick Bar Took to Complete Frank Coding Forum 3 03-16-2010 11:47 AM
Building a GAP Trading Strategy brownsfan019 The Candlestick Corner 41 08-06-2009 12:54 PM
Adding Sound to Your Indicator (EasyLanguage) Tams Coding Forum 33 05-10-2009 08:58 AM
building a track record? darthtrader Market Analysis 7 06-23-2007 12:19 AM
Building a Computer System wsam29 General Discussion 5 03-04-2007 07:28 PM

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