Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (howardR), 650 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Help with sorting data array #485960
05/18/22 10:23
05/18/22 10:23
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
Hi,
I am trying to sort a data array using the sort functions available in the manual. However, i cannot get it to sort and just returns zero on the plot. Could someone please bump me in the right direction?


Code
function run() 
{
	set(LOGFILE);
	BarPeriod = 15;
	StartDate = 2020;
	EndDate = 2021;
	LookBack = 1440;

	asset("EUR/USD");

	var* Data = series(price());
	var* Ranks;
	int Length = 50;

	int A2V = sortRank(var* Ranks, var* Data, int Length);
	int A3V = sortIdx(var* Data, int Length);
	int A4V = sortData(var* Data, int Length);
	
}


Thanks,

Re: Help with sorting data array [Re: degenerate_762] #485962
05/18/22 11:13
05/18/22 11:13
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
The plots are as follows. sortData returns an error so i commented it out. Just trying to sort a series of prices in ascending or descending order.

Last edited by degenerate_762; 05/18/22 12:20.
Re: Help with sorting data array [Re: degenerate_762] #485963
05/18/22 11:22
05/18/22 11:22
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
sortData error is "cannot convert void to long". commenting out the left hand side eliminates the error. Is there a way to return the sortData into an array? sortRank and sortIdx return 0 on the plots.

Last edited by degenerate_762; 05/18/22 12:22.
Re: Help with sorting data array [Re: degenerate_762] #485964
05/18/22 11:24
05/18/22 11:24
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Plot is for vars. You cannot plot ints. Plotting an index makes no sense anyway since you will likely get a flat line.

Re: Help with sorting data array [Re: degenerate_762] #485965
05/18/22 11:26
05/18/22 11:26
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
You already declared Data, Ranks & Length, so why would you declare them again in the sort functions?

Last edited by Grant; 05/18/22 12:31.
Re: Help with sorting data array [Re: degenerate_762] #485966
05/18/22 11:30
05/18/22 11:30
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
Only findIdx returns a value other than 0. "Returns the index of the highest Data element below or equal to Value, or -1 when no such element was found. ". Ok!.

please bump me! for i have sinned and i know nothing.


Attached Files
FS8_RTJWAAA6yp_.jpg (66 downloads)
Last edited by degenerate_762; 05/18/22 12:22.
Re: Help with sorting data array [Re: Petra] #485968
05/18/22 11:51
05/18/22 11:51
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
@Petra, I see that sortIdx, sortRank , and findIdx return int* / int. Makes sense for plot to return a constant. Ok. what does sortData return? int, var, vars ? i get the error cannot convert void to long. also if they return integers, how would i get the sorted array? it returns an integer while the sorted array of size length is of interest.

Re: Help with sorting data array [Re: Grant] #485969
05/18/22 11:53
05/18/22 11:53
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
@Grant, thanks.

Re: Help with sorting data array [Re: degenerate_762] #485970
05/18/22 12:03
05/18/22 12:03
Joined: Jul 2021
Posts: 51
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 51
@Petra, it returns int. plot the xxx as that it a vars. thanks

Last edited by degenerate_762; 05/18/22 12:23.
Re: Help with sorting data array [Re: degenerate_762] #485971
05/18/22 12:14
05/18/22 12:14
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
sortData returns nothing. It sorts the data. The other functions return the index array pointer.

When you look up a function in the manual, you can see if and what it returns after the function parameters. *int means it returns an int array.

Page 1 of 2 1 2

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