Hello,

Oh my God! It does not only re-iterates for all stocks BUT repeating it 
for ALL bars
A MUST-READ is this: http://www.amibroker.com/guide/x_performance.html

Follow advice given in the article and MOVE LOOP INVARIANTS OUTSIDE THE 
LOOP !

Better yet REMOVE THIS code altogether.
You don't need this.
Instead use PositionScore that does the ranking for you !
This is a 2nd must read:
http://www.amibroker.com/guide/h_portfolio.html

If you need to access rankings use custom backtester - the signal array 
will have all symbols sorted by absolute
value of position score on bar by bar basis - it will be many orders of 
magnitude
faster than your code.

Best regards,
Tomasz Janeczko
amibroker.com

On 2010-04-08 21:52, mkecera wrote:
> Hi All,
>
> I am using the function below to get ranking of particular stock in the 
> watchlist according to defined function. Problem is that for backtest its too 
> slow as it recalculates for each stock.
>
> Is there a way to store the rankings once and then just read them or pass 
> them between different stocks during portfolio backtest?
>
> Any pointers are greatly appreciated. Thank you.
>
> function GetValue(index)
>       {
>       return C[index];
>       }
>
> for (z=1; z<=BarCount-1; z++)
> {
>       local List;
>
>     List = CategoryGetSymbols( categoryWatchlist, WatchlistNumber );
>
>     for( i = 0; ( SymbolNumber= StrExtract( List, i ) ) != ""; i++ )
>     {
>       SetForeign(SymbolNumber);
>       TemporaryValue = GetValue(z);
>       RestorePriceArrays();
>       TickersValue[i] = TemporaryValue;
>     }
>
>       MyPosition[z]=0;
>       for( n = 0; n<=i; n++ )
>     {
>       
> MyPosition[z]=IIf(MyValue[z]<TickersValue[n],MyPosition[z]+1,MyPosition[z]);
>     }
> }
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>
>
>    

Reply via email to