Hello,

Thank you.

I came up with the code below. So signal array has ALL the symbols sorted or 
just the ones which passed the BUY rules? Because I want to sort ALL the 
symbols first and then apply some BUY rules on the first five symbols. 

Again thanks for your help.

SetCustomBacktestProc("");
if (Status("action") == actionPortfolio) 
        {
    bo = GetBacktesterObject(); 
    bo.PreProcess();    
    for (i = 0; i < BarCount; i++)      
    {
         Counter[i]=0;
        for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
        {        
                 Counter[i]=Counter[i]+1;
                        if (Counter[i]>5){sig.PosSize=0;}
             }  
        bo.ProcessTradeSignals(i);      
    }   
    bo.PostProcess();
}


--- In [email protected], Tomasz Janeczko <gro...@...> wrote:
>
> Hello,
> 
> Using GetFirstSignal/GetNextSignal methods.
> When you iterate using those functions you will get the list of
> symbols sorted by absolute value of positionscore.
> For more info see:
> http://www.amibroker.com/guide/a_custombacktest.html
> and
> http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> 
> On 2010-04-08 22:23, mkecera wrote:
> > Fast response! Thank you. Can you be more specific on how to access 
> > rankings using custom backtester?
> >
> > --- In [email protected], Tomasz Janeczko<groups@>  wrote:
> >    
> >> 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
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>        
> >>      
> >
> >
> >
> > ------------------------------------
> >
> > **** 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