Hello,

I am a fairly new AmiBroker user, and I am trying to code up a 
Sector Ranking tool. (Using FOR loops, which is inefficient)  My 
intent is to run this every so often and then insert the results 
into a trading system to help adjust positionscore and buy/sell 
indicators.  

Below is the code I am using.  However, when I try to run this 
forother than the current day, each day comes up with the same 
scores.  I believe it is probably due to the third FOR loop (which I 
founhd int he AmiBroker users guide), but I am unsure why.  Also, is 
there a way to use indicators like MACD on Foreign(ie not current) 
stocks?

Thanks in advance for any help you can provide,

James

//This is a Sector Ranking exploration                  
 
Filter = 1; 
  
for (i= 0; i<1; i++)
        {
   Seclist = CategoryGetSymbols(categorySector, i); 

   SecSum = 0;
   NumSec = 0;
   NullSec = 0;
   x = 0;
   y1 = 0;
   y2 = 0;
   SectorRelStrength = 0;

   for( k = 0; ( sym = StrExtract( Seclist, k ) ) != ""; k++ ) 
      { 
        x = Foreign( sym, "close");
                y1 = MA(x,3);   
       y2 = MA(x,10);
    
        if (x[BarCount-1] != 0) // Verify current symbol has data 
associated with it
        {

                        for( m = BarCount-7; m < BarCount; m++ ) 
                        { 
                                // Insert ranking rules here as 
if/else rules.
                                if( x[ m ] > y1[ m ] )
               SecSum[m] = SecSum[m]+1; 
                                else 
                             SecSum[m] = SecSum[m];
                        }

                NumSec = NumSec+1;
        }
     
        else
                NullSec = NullSec+1;


        }
        SectorRelStrength = SecSum[m-1]/NumSec[m-1];
  
  AddTextColumn( CategoryGetName( categorySector, i), "Sector 
name" );  
  AddColumn( SectorRelStrength, "SectorRelStrength", 1.4 );

Reply via email to