[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sortdown_a, sortup_a:sorting arrays



PureBytes Links

Trading Reference Links

Well, the functions seem to be quircky. The sortdown_a makes the following 
code go wrong. What I'm trying to do is tell the showme to find those S&R 
levels that have less than 3.1 points between them, and to then plot their 
average.

vars:sort(0),var1(0),var2(0);

array:ar[15](0);

ar[1]=1000;
ar[2]=998;
ar[3]=1004;
ar[4]=1008;
ar[5]=1010;
ar[6]=1014;
ar[7]=1018;
ar[8]=1020;
ar[9]=1024;
ar[10]=1026;
ar[11]=1030;
ar[12]=1032;
ar[13]=1036;
ar[14]=1040;
ar[15]=1042;

sort=sortdown_a(ar,15);

{This is supposed to make ar[1] be equal to 1042, ar[2] equal to 1040, etc.}

array:ar2[14](0);

for var1=1 to 14 begin
	var2=var1+1;
if var2<16 then begin
	if ar[var1]-ar[var2]<3.1 then ar2[var1]=(ar[var1]+ar[var2])/2;

end;
end;

plot1 (ar2[1]);
plot2 (ar2[2]);
plot3 (ar2[3]);

Now, being that we have at least three instances where the difference 
between the levels was less than 3.1points, these plots should draw their 
averages. instead, it just draws one, and the other lines are rubbish.

I'd really appreciate any help with this!

TIA

Philip