Posted By: Smon
Pointer-trouble with dataAppendRow() - 06/14/20 11:47
When I'm running the script below, I'm getting this:
...
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:
Sorry for reposting this problem. I deleted the old thread because my demo script was too complicated.
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.