Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (flink, AndrewAMD, TipmyPip, 1 invisible), 667 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to generate volume/dollar bars? #475755
01/06/19 20:28
01/06/19 20:28
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
I know we can generate custom bars with the bar function.
I tried creating volume bars using variants of the code below, but it doesnīt look like expected. Atleast the plot does not reflect bars that contain atleast a volume of 500.
Can we create volume/dollar bars?

Code:
static int vol = 0;

int bar(vars Open, vars High, vars Low, vars Close)
{
	vol += marketVol();
	if (vol >= 500) {
		vol = 0;
		return 1;
	}
	return 4;
}


Last edited by Dalla; 01/06/19 20:29.
Re: How to generate volume/dollar bars? [Re: Dalla] #475825
01/09/19 08:13
01/09/19 08:13
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Depends on the volume, Your code would work if marketVol is the volume of the last quote. If it is something different or no volume at all, modify the code or generate other types of bars.

Re: How to generate volume/dollar bars? [Re: jcl] #475827
01/09/19 08:46
01/09/19 08:46
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
Consider the following code, where marketVol does contain the volume

Code:
// Custom Bars
static int vol = 0;

int bar(vars Open, vars High, vars Low, vars Close)
{
	//printf("nVol %i", vol);
	vol += marketVol();
	if (vol >= 500) {
		vol = 0;
		return 1;
	}
	return 4;
}

function run() {
	set(TICKS);
	StartDate = 20150101;
	EndDate = 20150115;
	set(PLOTNOW);
	BarPeriod = 10;
	vars Close = series(priceClose());
	plot("Vol",marketVol(),NEW,RED);
}



This leads to the attached (zoomed in) chart, where all bars have a volume less than 500. I would expect them to be > 500 ?

Attached Files
Re: How to generate volume/dollar bars? [Re: Dalla] #475834
01/09/19 19:18
01/09/19 19:18
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Why do you think they have a volume less than 500? I see nowhere their volume.

Re: How to generate volume/dollar bars? [Re: jcl] #475845
01/10/19 04:29
01/10/19 04:29
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
Did you check the attached file? The volume is plotted below the price chart

Re: How to generate volume/dollar bars? [Re: Dalla] #475846
01/10/19 06:39
01/10/19 06:39
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I see only a marketVol plot. Plot the bar volume instead. You can get it with a tick function and the same formula that you used for your bars.

Re: How to generate volume/dollar bars? [Re: jcl] #475848
01/10/19 07:01
01/10/19 07:01
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
OK, there is something I'm missing here.
How do I get the bar volume? And what is it that I'm plotting now? (that I thought was the bar volume)

Re: How to generate volume/dollar bars? [Re: Dalla] #475849
01/10/19 07:05
01/10/19 07:05
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I don't know what it is. It depends on your broker. But it is not the volume of your bars.

Re: How to generate volume/dollar bars? [Re: jcl] #475850
01/10/19 08:09
01/10/19 08:09
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
This is FXCM data, so as per the manual, itīs "Tick frequency in live data and in historical data." I still donīt understand what is the difference between this and the volume of the bar?

Re: How to generate volume/dollar bars? [Re: Dalla] #475853
01/10/19 08:50
01/10/19 08:50
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The tick frequency is the number of quotes per minute.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1