Gamestudio Links
Zorro Links
Newest Posts
SGT_FW
by Aku_Aku. 11/30/26 08:19
Removing outliers from files
by JeyKey II. 11/29/26 10:01
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 12,233 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 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: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
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: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
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: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
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: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
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: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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


Moderated by  Petra 

Gamestudio download | 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