PureBytes Links
Trading Reference Links
|
Can we use a quad or dual processor computer to
reduce run time?
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Jason
Hart
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: 08/01/2004 10:19 PM
Subject: Re: [amibroker] any ideas to
reduce runtime for the price RS ranking code?
Jesus Charles! What is in that formula? I just pasted it into
AA and ran it on a watchlist of 150 stocks and I thought my computer was going
to catch on fire!!firstview2000 <<A
href="">firstview2000_1999@xxxxxxxxx>
wrote:
<BLOCKQUOTE class=replbq
>Hi,With
the following code, it takes me over 40 minutes to run a database of 700
tickers. This code calculates 2 ratings, one for stocks and one for
indices.Can anyone suggest some good ways to reduce the runtime
?TIA.Charles/*** Price Relative Strength
Ranking***/// use this function to calculate self relative
strength// The funciton takes care of stocks with several quote
length// It returns the calculated relative strength arrayfunction
selfRelStrength (myArray){ sRelStren =
IIf((IsNull(ROC(myArray, 260)) == False),
ROC(myArray, 260) + ROC(myArray, 195) +
ROC(myArray, 130) + 2 * ROC(myArray, 65),
IIf
( (IsNull(ROC(myArray, 195)) == False),
ROC(myArray, 195) + 2 * ROC(myArray, 130)
+ 2 * ROC(myArray, 65),
2 *
ROC(myArray, 130) + 3 * ROC(myArray, 65) ));
return sRelStren;}//replace your watchlist number with
0//list = CategoryGetSymbols( categoryWatchlist, 0 );list =
CategoryGetSymbols( categoryMarket , 0 ) + CategoryGetSymbols(
categoryMarket , 1 );Count = 0;rank = 0;relval = 0;n
= 0;CountIdx = 0;rankIdx = 0;relvalIdx = 0;nIdx =
0;// price change for the current symbolOwnVal =
selfRelStrength(C);for( i = 0; ( sym = StrExtract( list, i ) ) !=
""; i++ ){
SetForeign(sym); if (IsIndex())
{
relValIdx =
Nz(selfRelStrength(C));
RestorePriceArrays();
nIdx
= Nz(IIf(relValIdx != 0, 1,
0)); //
count if there is a price change
// now, add up counts for all symbols with
price change in the specified period
CountIdx = CountIdx +
nIdx;
rankIdx = IIf (relValIdx > OwnVal, rankIdx + 1,
rankIdx);
} else {
relVal =
Nz(selfRelStrength(C));
RestorePriceArrays();
n
= Nz(IIf(relVal != 0, 1,
0)); //
count if there is a price change
// now, add up counts for all symbols with
price change in the specified period
Count = Count +
n; rank
= IIf (relVal > OwnVal, rank + 1,
rank); }}rankPerc = int(100 *
(Count - rank) / Count);rankPercIdx = int(100 * (CountIdx - rankIdx)
/ CountIdx);// filter out any stocks that dont have recent quotes (1
month)// this is done via comparing with $compxCurrentDay =
Now(3); // get
system date with dateNum formatCurrDayAgo = CurrentDay -
100;LastDay = LastValue(DateNum());// donot rank DATAONLY
tickers (in Market #3)Filter = (CurrDayAgo <= LastDay) AND
(MarketID() != 3);if (Status("action") == 4) {// code running in
explorationSetOption("nodefaultcolumns", True
);AddTextColumn(Name(),"Ticker");AddColumn(Close,"Close",
1.2);// AddColumn(Count,"count", 1.0);AddColumn(rank,"rank#",
1.0);AddColumn(Ownval,"Perf",1.2);AddColumn(rankPerc,"rank%",1.0);AddTextColumn(IndustryID(1),"Industry");AddColumn(rankIdx,"rankIdx#",
1.0);AddColumn(rankPercIdx,"rankIdx%",1.0);}Check
AmiBroker web page at:<A
href="">http://www.amibroker.com/Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Do you Yahoo!?<A
href="">New
and Improved Yahoo! Mail - Send 10MB messages! Check AmiBroker
web page at:<A
href="">http://www.amibroker.com/Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|