Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 907 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pointer-trouble with dataAppendRow() #480548
06/14/20 11:47
06/14/20 11:47
Joined: Dec 2014
Posts: 206
Germany
Smon Offline OP
Member
Smon  Offline OP
Member

Joined: Dec 2014
Posts: 206
Germany
When I'm running the script below, I'm getting this:


Quote

...
Rows: 91
Values sent : wdate() = 42011.87500, price = 1.18396, atr = 0.00221
Values received: wdate() = 42011.87500, price = 0.00000, atr = 1.89799
...


The values in the 2nd and 3rd line should be exactly the same. I must be doing something wrong, but what's my mistake?

This is my script:

Code
function run() 
{
	int cols = 3; //number of columns of the dataset
	int handle = 100; //can be any number between 1..1000
	
	if(is(INITRUN))
	{
		dataNew(handle, 0, cols); 
	}

	var* row = dataAppendRow (handle, cols);
	row[0] = wdate();   //mandatory for datasets
	row[1] = price();     //just some data
	row[2] = ATR(30);  //just some data
	
	int rows = dataSort(handle); //make sure, timestamps are in descending order
	int idx = dataFind(handle, wdate());
	
	printf("\n\nRows: %d", rows);
	printf("\nValues sent      : wdate() = %.5f, price = %.5f, atr = %.5f", wdate(), price(), ATR(30));
	printf("\nValues received: wdate() = %.5f, price = %.5f, atr = %.5f", dataVar(handle, idx, 0), dataVar(handle, idx, 1), dataVar(handle, idx, 2));
}


Sorry for reposting this problem. I deleted the old thread because my demo script was too complicated.

Last edited by Smon; 06/14/20 11:56.
Re: Pointer-trouble with dataAppendRow() [Re: Smon] #480823
07/17/20 07:29
07/17/20 07:29
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
In case you have not found the problem yet, it's here:

var* row = dataAppendRow (handle, cols);

A var is 8 bytes, but the elements of a database record, except the first, have a size of 4 bytes.


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