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

[amibroker] To continue with



PureBytes Links

Trading Reference Links




Here is an even shorter code to find the top10 StochD values 
from the last 100 bars.
Paste in indicator builder the
 
// Top10 from 100
<FONT 
size=2>R=StochD();H0=StochD();L1=LastValue(Cum(1));N=100;// the 
lookback periodTOP=10;// the topX 
calibrationfor(K=1;K<=TOP;K++){H1=LastValue(HHV(H0,n));BAR1=LastValue((ValueWhen(H0==H1,Cum(1)-1)));H0[BAR1]=-10;}Plot(IIf(Cum(1)>L1-N,R,-1E10),"",IIf(H0==-10,colorYellow,colorBlack),2);
 
Since we paint the 
top10 points outside the loop execution, we know all the rest details, when it 
happened, the respected value, outside the loop, 
consequently the 
result is ready for any further use.
The trick was to find 
the highest value, find the bar it happens and then, in the very next step, make 
this value negative [-10 in the example]. 
The next cycle of the 
loop will search for the 2nd highest value 
etc.
For other indicators, 
replace -10 with another, enough negative value, lower than the usual indicator 
values, to ensure that you will excude this
bar from the next 
cycle of the loop. If you do not know the negative values, a Lowest(Indicator)-1 
is enough.
Dimitris 
Tsokakis
 
----- Original Message ----- 
From: <A 
href="" title=tsokakis@xxxxxxxxx>Dimitris Tsokakis 

To: <A href="" 
title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
Sent: Saturday, September 06, 2003 10:59 PM
Subject: To begin with

Let us find the top10 of the last 100 Stochd() 
values.
In AA explore the current stock for the last 100 
bars.
// The top10 of an exploration
<FONT 
size=2>bars=100;H1=StochD()*(LastValue(Cum(1))-Cum(1)<bars);H11=H1;H2[0]=0;Counter=0;top=10;for(n=1;n<=top;n++){for(i=1;i<BarCount;i++){H2=LastValue(Highest(H1));if(H1[i]==H2[i]){if(Counter<top){H1[i]=0;Counter=Counter+1;}}}}Filter=1;AddColumn(H11,"Array");AddColumn((H1==0)*H11,"Top10");
 
In the "Top10" column you read the 10 highest StochD() values, 
all the rest are 0.
Dimitris Tsokakis






Yahoo! Groups Sponsor


  ADVERTISEMENT











Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
1top10.gif

Attachment: Description: "Description: GIF image"