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

[amibroker] Re: Are dynamic arrays possible in AB?



PureBytes Links

Trading Reference Links

I have almost got his working except for the following: the indicator 
that I am plotting disappears and re-appears on alternating clicks of 
my mouse ???? I have tried hardcoding numbers in place of Barcount
and I have tried adding the line : SetBarsRequired(10000,10000); but 
with no difference. I am first creating and storing a ranked and 
sorted list of 200 stocks using the following (AFL_File#1), which I 
am confident is working properly and not part of the problem. This 
stores my ranked and sorted list in a binary file. I then use 
(AFL_File#2) in an indicator window and it succesfully retrieves the 
data I want to plot from the binary file but the plotted indicator 
diasppears and comes back with each mouse click. Any ideas on how I 
can prevent this?
Thanks,
Tom

//AFL_File#1
osInitialize();
List = GetCategorySymbols(categoryWatchlist, 10);
table=osTabCreate();  
osTabAddColumn( "Ticker", 2, table, 25 );

for( j = 0; j <= BarCount-1; j++ )
{
  osTabAddColumn( "Score"+j, 1, table );
  osTabAddColumn( "rank"+j, 1, table );
}
for(i=0; ( ticker = StrExtract( List, i ) ) != ""; i++)
{
SetForeign(ticker);
osTabSetString( ticker, i, 0, table );
 for( j = 0; j <= BarCount-1; j++)
 {
 osTabSetNumber( score[j] = LastValue(Ref(((ROC(C,5) + ROC(C,15) + 
ROC (C,25) + ROC(C,35)) / 4),-BarCount+1+j)) , i, 2 * j + 1, table );

 }
}
RestorePriceArrays();
for( j = 0; j <= BarCount-1; j++)
{
osTabSort( table, 2 * j + 1, False ); //score
for(n = 0; n<= i -1; n++)
      {
        osTabSetNumber(n+1,n,2 * j + 2,table); //rank
      }
}
osTabSort( table, 0 , True ); // reorder by ticker#
osTabDelete( table );

//AFL_File#2
osInitialize();
table2 = osTabCreate();

for( j = 0; j <= BarCount-1; j++)
{
ID1[j] = osTabGet(0, 2 * j + 2, table2);
}
osTabDelete( table2 );

Plot(ID1, "!ID1 rank", colorRed ); 




--- In amibroker@xxxxxxxxxxxxxxx, "trb0428" <tombrowne34@xxx> wrote:
>
> Graham,
> 
> Thanks. I find the sorting and ranking within the Osaka routines to 
> be very fast. I am going to try saving a binary version of the 
table 
> created using Osaka and then from within my indicator code recall 
and 
> load the table into memory and index into it for just the rank of 
the 
> ticker I have displayed in my chart therfore only needing to create 
> one array instead of 200 which I think (hope?) I can do.  I think I 
> should then be able to plot this without incurring a performance 
> penalty.....thanks for your help.
> 
> regards,
> Tom 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >
> > If you need the value for every bar then you will need to run the 
> ranking
> > for every bar, including creating the data files for every bar. 
ie 
> within a
> > loop
> > There are some sort and rank AFL in a library that allow similar 
> ranking
> > using staticvarget, but again these will need changing to within 
a 
> loop to
> > get the ranked values for every bar.
> > Just remember that sorting symbols against each other will slow 
the
> > execution down by a very large amount, the more symbols and more 
> bars
> > included will determine the boredom time you will encounter
> > 
> > -- 
> > Cheers
> > Graham
> > AB-Write >< Professional AFL Writing Service
> > Yes, I write AFL code to your requirements
> > http://www.aflwriting.com
> > 
> > 
> > On 11/01/07, trb0428 <tombrowne34@> wrote:
> > >
> > > Hi Graham,
> > >
> > > I am using the Osaka plugin to rank and sort a list of stocks.
> > > From this, I am trying to create an indicator which will 
display 
> the
> > > rank of the stock for each bar. I have 200 symbols that I am 
> sorting
> > > and rankng.
> > >
> > > Below is the code I am using to read from the Osaka table into a
> > > single array ( only works for one ticker). I was hoping to be 
> able to
> > > create (dynamically) the 200 arrays I need to hold the rank 
> numbers
> > > for each day for the 200 tickers using something within the 
loop 
> like:
> > >
> > > myarray = "ID"+n;
> > > myarray = ID;
> > >
> > > but I know this doesn't work.
> > >
> > > Can I accomplish this with VarSet/VarGet as you suggest?
> > >
> > >
> > > for (n = 0; n<= tickers-1; n++) //n is the rows representing 
> tickers
> > >     {
> > >
> > >      for( j = period-1; j <= BarCount-1; j++) // j*2+2 holds 
the 
> rank
> > >          {
> > >              ID[j] = osTabGet( n, 2 * j + 2, mytable );
> > >
> > >           }
> > >        myarray = "ID"+n; // <-- this does not work
> > >        myarray = ID; // <-- this does not work
> > >     }
> > >
> > > Thanks,
> > > Tom
> > >
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> > > >
> > > > Tom
> > > > Exactly what are you trying to achieve? What are the arrays ?
> > > > btw Varset is an array, staticvarset is a single value
> > > >
> > > >
> > > > VarSet("Close",C);
> > > > Plot(VarGet("Close"),"Close",colorBlue,styleLine);
> > > >
> > > >
> > > > --
> > > > Cheers
> > > > Graham
> > > > AB-Write >< Professional AFL Writing Service
> > > > Yes, I write AFL code to your requirements
> > > > http://www.aflwriting.com
> > > >
> > > > On 11/01/07, trb0428 <tombrowne34@> wrote:
> > > > >
> > > > > Ara,
> > > > >
> > > > > My goal is to plot the data. I do not see how I can use this
> > > > > structure to plot? Is there a way to store this element by 
> element
> > > > > data into an artificial ticker symbol. I have thought of
> > > > > impplementations using ATC but cannot arrive at a solution 
> this
> > > way???
> > > > > Is there any other way to store this data?
> > > > >
> > > > > Thanks for your suggestions.
> > > > >
> > > > > regards,
> > > > > Tom
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@> 
> wrote:
> > > > > >
> > > > > > Use VarSet() and VarGet() functions. These are non array
> > > elements,
> > > > > but you
> > > > > > can create them dynamically so you can set and read them 
in 
> a
> > > loop
> > > > > as array
> > > > > > elements.
> > > > > >
> > > > > > for (i=1; i<10; i++)
> > > > > > {
> > > > > > //create element name
> > > > > > Array_element = "Arr_item" + i;
> > > > > > VarSet(Array_element,desired_value);
> > > > > > }
> > > > > >
> > > > > > x = VarGet("Arr_item1");
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "trb0428" <tombrowne34@>
> > > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > > Sent: Tuesday, January 09, 2007 1:39 PM
> > > > > > Subject: [amibroker] Are dynamic arrays possible in AB?
> > > > > >
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have a need to create arrays dynamically. Is this 
> possible?
> > > I
> > > > > have
> > > > > > > tried several ways including the following but without
> > > success:
> > > > > > >
> > > > > > >
> > > > > > > for (n = 0; n<= tickers-1; n++)
> > > > > > >    {
> > > > > > >
> > > > > > >       for( j = period-1; j <= BarCount-1; j++)
> > > > > > >          {
> > > > > > >
> > > > > > >             ID[j] = osTabGet( n, 2 * j + 2, mytable );
> > > > > > >
> > > > > > >           }
> > > > > > >        myarray = "ID"+n;
> > > > > > >        myarray = ID;
> > > > > > >    }
> > > > > > >
> > > > > > > Tom
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Please note that this group is for discussion between 
> users
> > > only.
> > > > > > >
> > > > > > > To get support from AmiBroker please send an e-mail 
> directly
> > > to
> > > > > > > SUPPORT {at} amibroker.com
> > > > > > >
> > > > > > > For NEW RELEASE ANNOUNCEMENTS and other news always 
check
> > > DEVLOG:
> > > > > > > http://www.amibroker.com/devlog/
> > > > > > >
> > > > > > > For other support material please check also:
> > > > > > > http://www.amibroker.com/support.html
> > > > > > >
> > > > > > > Yahoo! Groups Links
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Please note that this group is for discussion between users 
> only.
> > > > >
> > > > > To get support from AmiBroker please send an e-mail 
directly 
> to
> > > > > SUPPORT {at} amibroker.com
> > > > >
> > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check 
> DEVLOG:
> > > > > http://www.amibroker.com/devlog/
> > > > >
> > > > > For other support material please check also:
> > > > > http://www.amibroker.com/support.html
> > > > >
> > > > > Yahoo! Groups Links
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > > Please note that this group is for discussion between users 
only.
> > >
> > > To get support from AmiBroker please send an e-mail directly to
> > > SUPPORT {at} amibroker.com
> > >
> > > For NEW RELEASE ANNOUNCEMENTS and other news always check 
DEVLOG:
> > > http://www.amibroker.com/devlog/
> > >
> > > For other support material please check also:
> > > http://www.amibroker.com/support.html
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
>



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/622 - Release Date: 1/10/2007 2:52 PM