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
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 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
sortIdx #464838
03/14/17 17:16
03/14/17 17:16
Joined: Jul 2016
Posts: 51
H
hatten Offline OP
Junior Member
hatten  Offline OP
Junior Member
H

Joined: Jul 2016
Posts: 51
When using sortIdx I run into the problem that this function apparently checks the lookback period and yields and error if the number of elements of the array you wish to sort exceeds the lookback period. However I do wish to sort an array that is not a time series and whose dimension is unrelated to lookback issues. This function should be in file functions.c as it is declared in function.h. Unfortunately function.c is not part of the distribution, otherwise it would be easy to just copy the code for sortIdx and remove checklookback command, which I assume is the problem. Anyone has a code snippet for sorting as sortIdx does? The standard qsort c++ function is different as it rearranges the elements of the original array which I don't want.

Re: sortIdx [Re: hatten] #470424
01/13/18 15:09
01/13/18 15:09
Joined: Dec 2014
Posts: 204
Germany
Smon Offline
Member
Smon  Offline
Member

Joined: Dec 2014
Posts: 204
Germany
Same question here!


This doesn't work:


function main()
{
int n;
var myarray[4] = {1.5, 2.3, 0.1, 0.001};

int Idx = sortIdx(myarray, 4);

for(n=0, n < 4, n++)
{
printf("n%dth Index = %d",n,Idx[n]);
}


}

Re: sortIdx [Re: Smon] #470439
01/14/18 19:19
01/14/18 19:19
Joined: Dec 2013
Posts: 14
O
oligodar Offline
Newbie
oligodar  Offline
Newbie
O

Joined: Dec 2013
Posts: 14
This code works for me:

Code:
function main(){
	int n;
	var myarray[4] = {1.5, 2.3, 0.1, 0.001};
	int* Idx = sortIdx(myarray, -4);
	for(n=0; n < 4; n++){
	    printf("\n%dth Index = %d",n,Idx[n]);
	}
}




in zorro 1.744

Last edited by oligodar; 01/14/18 19:24.
Re: sortIdx [Re: oligodar] #470447
01/15/18 09:58
01/15/18 09:58
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
AFAIK, sortIdx does not check the lookback period and the number of elements does not matter. Maybe you were using a very old Zorro version.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1