Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, TipmyPip, Quad, AndrewAMD), 904 guests, and 7 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
Generic Tick Data Support #481283
08/21/20 15:21
08/21/20 15:21
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

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

The dataset functions allow us to store tick data with any arbitrary number of fields.

Likewise, I think it would be useful if any arbitrary tick data can be sourced in a variant of the tick() function.

Take, for example, a market depth trading application. I can live-record market depth ticks. I define my own tick, like so:

Code
typedef struct DEPTHTICK{
	DATE time; // [0]
	float fPrice; // [1] price data, positive for ask and negative for bid
	float fQty; // [2] quantity at price level's ask or bid
} DEPTHTICK;
So this struct has two fields and a timestamp.

Or maybe I wanted double precision for some reason, because the Asset price data is strange. And the price data can be negative, so let's add some flags. Then I'd do something like this:
Code
typedef struct DEPTHTICKv2{
	DATE time; // [0]
	var vPrice; // [1,2] price data
	float fQty; // [3] quantity at price level's ask or bid
	int flags; // [4]
} DEPTHTICKv2;
In this case, we have four fields and a timestamp. (Two are occupied by double precision.)

In a backtest, I would like to source this generic tick data.

On Init, I call a function that sources the dataset file. I tell the function how many fields there are (two). It returns a handle, int h.

As the backtest proceeds, Zorro invokes a user-supplied function generic_tick(int h, void* pTick), where h is the handle, and pTick is the pointer to my user-defined tick for the given timestamp.

Re: Generic Tick Data Support [Re: AndrewAMD] #481296
08/23/20 16:58
08/23/20 16:58
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
One minor correction to the above (I cannot edit my previous post):
Quote
Fields - Number of fields per record, including the date field.
https://manual.zorro-project.com/data.htm

So in the above examples, they should be three and five fields, respectively.

Re: Generic Tick Data Support [Re: AndrewAMD] #481302
08/24/20 13:22
08/24/20 13:22
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Thanks, this seems to me a useful feature.

Re: Generic Tick Data Support [Re: AndrewAMD] #485762
04/20/22 11:04
04/20/22 11:04
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I don't think this feature was ever added, was it? It really would be useful, especially in [Test] and [Train] modes.

I just want a callback that outputs ticks for all loaded datasets.

Re: Generic Tick Data Support [Re: AndrewAMD] #485765
04/20/22 14:00
04/20/22 14:00
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I believe it's possible since a while, but not with a callback. You can read an arbitrary tick from a dataset with a code like this:

DEPTHTICKv2* MyTick = (DEPTHTICKv2*) dataStr(Handle,dataFind(Handle,wdate(),0)):

Re: Generic Tick Data Support [Re: AndrewAMD] #485767
04/20/22 14:16
04/20/22 14:16
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
OK, but I'd like a callback for the same reason that tick() was implemented.

Basically, ticks of arbitrary type can arrive at different frequencies than real ticks. In other words, this can happen, in this sequence:

tick()
tick()
tick()
generic_tick()
generic_tick()
generic_tick()
generic_tick()
tick()
tick()
tick()
generic_tick()
generic_tick()
generic_tick()
generic_tick()

The idea is to guarantee that all ticks will be caught in all circumstances.

Re: Generic Tick Data Support [Re: AndrewAMD] #485775
04/20/22 18:09
04/20/22 18:09
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
If I understood it right, it can still be done with 2 lines in a tick function.

while(dataVar(H,N,0) <= wdate(0))
generic_tick(H,dataStr(H,N--,0));

N must be set to the earliest record number at start.

Re: Generic Tick Data Support [Re: AndrewAMD] #485776
04/20/22 18:32
04/20/22 18:32
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
That should work just fine for my purposes. Thanks!


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