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

RE: Sortdown_a, sortup_a:sorting arrays



PureBytes Links

Trading Reference Links

i couldnt sleep so i thought i throw some light on you problem.
i have no idea what exacctly you are trying to do but i think there is a
problem in you programming logic. Use
the code below and run it on you chart.... in the easylanguage power editor
there is a debug window the "print " statement prints to this debug
window....then it just a matter of finding you problem ....easy
Cheers
goodluck
Cameron

run this edited code below
{....................................................}

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;
if currentbar = 1 then begin
sort=sortdown_a(ar,15);
print (sort);
print (ar[1]);
print (ar[2]);
print (ar[3]);
print (ar[4]);
print (ar[5]);
end;

{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 currentbar = 1 then begin
 print (var1);
 print (var2);
 print("debug area 1....ar[var1]
"+numtostr(var1,0)+"="+numtostr(ar[var1],0)+" ar[var1]
"+numtostr(var2,0)+"="+numtostr(ar[var2],0)+"
difference="+numtostr(ar[var1]-ar[var2],0));
 if ar[var1]-ar[var2]<3.1 then print("if ar[var1]-ar[var2]<3.1 then
condition is true");
end;

if ar[var1]-ar[var2]<3.1 then ar2[var1]=(ar[var1]+ar[var2])/2;

if currentbar = 1 then begin
 if ar[var1]-ar[var2]<3.1 then
print("ar2[var1]"+numtostr(var1,0)+"="+numtostr( (ar[var1]+ar[var2])/2,0));
end;

end;
end;


if currentbar = 1 then begin
 print ("results...ar2[1]="+numtostr(ar2[1],0)+"
ar2[2]="+numtostr(ar2[2],0)+" ar2[3]="+numtostr(ar2[3],0));
end;

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

{...........................................................................
.....................}

-----Original Message-----
From: Shraga(Feivi-Philip) [mailto:shraga@xxxxxxxxxxxx]
Sent: Friday, February 13, 2004 8:18 AM
To: Omega-list@xxxxxxxxxx
Subject: Sortdown_a, sortup_a:sorting arrays


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



---
---