Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
About marketVol() function #469022
11/02/17 17:49
11/02/17 17:49
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Hello.

I was wondering how the marketVol function is supposed to be used. When invoked, it returns unexpectedly small values only. When looking at daily asset data from stooq, market volume numbers are very large, going into hundreds of millions, whereas Zorro returns values in the ones and tens. Upon investigation, it looks like the application returns only the first minute volume value, and not the sum of all values within a bar. Consider this script:

Code:
#include <default.c>
#include <contract.c>

void main()
{
	BarPeriod = 1440;
}

void run()
{
	DATE date = wdate(0);
	long yyyymmdd = ymd(date);
	double vol = marketVol(0);
	printf("n%d volume: %f", yyyymmdd, vol);
}



And the attached image.

I am using the data from the Zorro website. But even if marketVol would return the sum, the number would still be relatively small. Like lets say 5 (approx. volume per minute) * 1440 (minutes) = 7200 (volume per day). This is far from the expected volume of hundereds of millions. In what unit are the Zorro data volume numbers?

The Manual says "trade volume per minute":
http://zorro-project.com/manual/en/price.htm
But if this is really only ever returning minute volume, how can the user access the daily/hourly/etc volume, when the given function argument takes a bar (as per BarPeriod) only?

I don't understand this. Any help appreciated. Thanks.

Attached Files
marketVol.png (26 downloads)
Last edited by pascalx; 11/02/17 18:24.
Re: About marketVol() function [Re: pascalx] #469024
11/02/17 19:12
11/02/17 19:12
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
That's because daily data (from Stooq etc) is stored differently than M1 data.

From an earlier post by jcl :

Originally Posted By: jcl
No, in D1 history there is no difference of start and end, since it has no hours. The date of the open is identical to the date of the close. This is considered by Zorro. Otherwise the calculation would be based on a wrong time, since a date literally begins at 00:00 and shifted to UTC you would get a date boundary between open and close.

But you would think Zorro would add up those bars anyways, right?

Re: About marketVol() function [Re: AndrewAMD] #469026
11/02/17 21:05
11/02/17 21:05
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Originally Posted By: AndrewAMD
That's because daily data (from Stooq etc) is stored differently than M1 data.

If the volume of M1 data is different to the volume of D1 data, how does someone convert the M1 volume to D1 colume when using BarPeriod = 1440 and M1 tick data?

Re: About marketVol() function [Re: pascalx] #469027
11/02/17 23:19
11/02/17 23:19
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Whoops, I forgot to address the elephant in the room:

Decentralized instruments will always have different tick volumes and/or volumes between exchanges. The SPX500 CFD is one of those instruments.

Next, I was unclear:
Quote:
If the volume of M1 data is different to the volume of D1 data, how does someone convert the M1 volume to D1 colume when using BarPeriod = 1440 and M1 tick data?

Assuming data is coming from the same data vendor (and using the same metric, not confusing tick volume with actual volume), 1440 M1 data points should always add up to the equivalent D1 bar. A D1 has a DATE float value rounded down to the nearest integer to indicate which day.

Could this be a Zorro D1 volume retrieval bug?

Re: About marketVol() function [Re: AndrewAMD] #469129
11/06/17 09:03
11/06/17 09:03
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
No, Zorro does nothing with volume. So what you do with the value returned by marketVol is completely up to the broker plugin and to your script. The "volume per minute" is a suggestion what _could_ be returned.

Re: About marketVol() function [Re: jcl] #469147
11/06/17 12:41
11/06/17 12:41
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Originally Posted By: jcl
No, Zorro does nothing with volume. So what you do with the value returned by marketVol is completely up to the broker plugin and to your script. The "volume per minute" is a suggestion what _could_ be returned.


Damn. This is troubling. I see MT4/5 does not even support volume data at all:
Quote:
marketVal: Not supported.
marketVol: Not supported in historical data, tick frequency in live data.

http://zorro-project.com/manual/en/mt4plugin.htm

Why is that? MT4 does know about volume.
Wouldn't it be natural to pass that in marketVol instead of 'tick frequency', whatever that is?
https://docs.mql4.com/predefined/volume

So you have marketVal and marketVol as additional, optional values. Any particular reason why 2?
Are 2 the maximum of optional data values someone ever needs?

This idea of a function called marketVol(int) (assuming "Vol" stands for "Volume") could return something other than volume looks like a design flaw. If the broker sends some other data for it, then ideally the user should not require to add checks in his code prior calling marketVol to make sure it is indeed a volume value. marketVol should just return 0, indicating that it has no known volume data from that current data source.

To accommodate arbitrary data values you would expect a marketVal(int index, int offset) function, where the given index selects the optional data values at their natural position. I would even consider to add a new data structure such as:

Code:
typedef struct T4X
{
	DATE time;	
	float fHigh, fLow;
	float fOpen, fClose;
	float* fVal;
} T4X;



Where the pointer of fVal would point to an additional series of arrays. This would allow for true arbitrary optional data values.

I would suggest to mark marketVol(int) and marketVal(int) as deprecated and add new functions marketSpread(int), marketVolume(int) and marketVal(int index, int offset).
marketSpread(int) and marketVolume(int) should return spread and volume if the system knows that the values are indeed what they promise, for example by the broker plugin, or t6 data files, otherwise 0.

Now to the next problem: How to correctly collect the optional asset data for a given bar. The current design gives the user no possibility to collect correctly. So marketVol(int) and marketVal(int) are useless in many cases. The proposed marketSpread(int) and marketVolume(int) functions could automatically solve this problem, because since they know what the value is, they can internally collect the value correctly. For example while priceHigh(int offset) collects the highest value within the bar, marketVolume(int) would collect the sum of all values within the bar. Sounds fair?

Now, what about marketVal(int index, int offset)? It probably needs a third parameter taking an optional function pointer to tell how data should be collected. So marketVal(int index, int offset, void* collectFunction), where the collect function could look something like

Code:
var collect(var collectedValue, var nextValue)
{
	return collectedValue + nextValue;
}

var collect(var collectedValue, var nextValue)
{
	return max(collectedValue, nextValue);
}



The collect function gets called by zorro for each data point within the given bar. This would enable the user to specify how zorro should collect the optional asset data. void* collectFunction should be a proper function pointer if Lite-C supports it.

Anyone agrees with this?

Re: About marketVol() function [Re: pascalx] #469148
11/06/17 14:33
11/06/17 14:33
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
That's unfortunately not our's to decide. Only prices are delivered by all brokers, any other data is up to the broker. If they deliver tick frequency instead of volume, marketVol returns the tick frequency. If they deliver spread, marketVal returns the spread. If they deliver nothing, the functions return 0. Different function names or bigger structs won't help.

For this reason, it makes no sense to guarantee a certain volume format. The only requirement is that marketVol returns at least some proxy of volume. Since almost all volume based indicators only use volume changes and not absolute volume, they will work. How useful such indicators are with a MT4 connection where volume is normally the tick frequency, is a different question.

Re: About marketVol() function [Re: jcl] #469151
11/06/17 16:22
11/06/17 16:22
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
jcl,

Can we add a new brokerCommand that allows the plugin to specify the output format of *pVolume? This way, Zorro would have no trouble determining how to handle the volume.

* New brokercommand: GET_BROKERASSET_VOLUME_TYPE - It will return the below values:
* 0: Not specified. Volume must be manually handled. (What Zorro does now.)
* -1: Absolute-point-of-reference number of ticks.
* -2: Number of ticks since last BrokerAsset call for this asset.
* -3: Frequency of ticks in ticks/minute.
* 1: Absolute-point-of-reference number of lots traded.
* 2: Number of lots traded since last BrokerAsset call for this asset.
* 3: Frequency of lot trades in lots/minute.

And then finally, on the user side, let the Zorro user specify how to interpret the historical volume with a similar type of flag.

Re: About marketVol() function [Re: AndrewAMD] #469152
11/06/17 16:50
11/06/17 16:50
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, that's certainly possible. I'll put it on our list.

Re: About marketVol() function [Re: jcl] #469155
11/06/17 18:33
11/06/17 18:33
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Originally Posted By: jcl
That's unfortunately not our's to decide. Only prices are delivered by all brokers, any other data is up to the broker. If they deliver tick frequency instead of volume, marketVol returns the tick frequency. If they deliver spread, marketVal returns the spread. If they deliver nothing, the functions return 0. Different function names or bigger structs won't help.

For this reason, it makes no sense to guarantee a certain volume format. The only requirement is that marketVol returns at least some proxy of volume. Since almost all volume based indicators only use volume changes and not absolute volume, they will work. How useful such indicators are with a MT4 connection where volume is normally the tick frequency, is a different question.


I don't see how this blocks a proper implementation of spread/volume/arbitrary asset data. In the case of MT4/MT5 the documentation clearly states that we have access to a volume value. We also have access to spread. Yet Zorro only delivers a tick frequency. Why?
https://docs.mql4.com/predefined/volume
https://docs.mql4.com/marketinformation/marketinfo

If the broker decides to send a garbage or no value for volume, and MT4/MT5 hands that garbage/no value to Zorro, why is that a problem Zorro would need to tackle, when the problem is on Broker/MT4 side? You also would not tackle the event if the broker would send garbage for open/high/low/close right? You just take the value as is in the remote platform and hand it over.

Furthermore I don't understand how the current implementation can be any satisfactory, nor do I understand how Andrews proposal fixes it all.

Summary of issues:
- Cannot access/use optional asset data values with BarPeriod > 1 (e.g. when backtesting .t6 data)
- Cannot retrieve volume and spread with MT4/MT5
- Limit of 2 optional asset data values. Cannot use 3 or more
- marketVol/marketVal might not be what they pretend to be / user has to find out / adapt code to different use cases

Originally Posted By: jcl
Different function names or bigger structs won't help.


I did not simply propose different function names or bigger structs. Was my previous text really that non-descriptive?

Page 1 of 3 1 2 3

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