Hi Richard, Take a look at the BarsSince() function. E.g. BarsSince(Cross(RSI(2), 90)); used in an exploration. You could than sort that column for the most recent or oldest. I'm not in AB at the moment, so haven't tested this, but think it's pretty straightforward (and faster than looping). If you wanted, you could also include this in a title so you would see the info on a stock by stock basis.
Peace and Justice --- Patrick ----- Original Message ----- From: Richard To: [email protected] Sent: Friday, January 08, 2010 3:12 PM Subject: [amibroker] Re: RSI(2) and AddToComposite Hello All, I have been following this post with interest. Thank you to everyone for the contribution. I have a question related to this subject. What is the simplest way to count how many days/bars the RSI(2) signal stays below/above certain level? For instance - count bars IF (RSI(2) < 5). Do I need to use looping code or "cum" may do the job? Regards Richard --- In [email protected], "NW Trader" <ta4cha...@...> wrote: > > Hi all > > Below (and attached) is another way to address the issue. While it may run much faster on longer watchlists, it does suffer from one problem that I haven't figured out how to address -- the total number of issues with RSI(2) over 90 is at the top of the column, however I haven't figured out how to export that total to use in creating a chart to track how the number compares to other market indices (something I'd like to do, preferably in a chart). If anyone else out there has solved this, I'd be grateful for some direction or code as I have several other instances of list totals that I'd like to chart. > > Thanks in advance for any solution. > > Peace and Justice --- Patrick > > //=============================================================================== > // Find the total number of issues with RSI(2) over 90 > // Run in Exploration against a watchlist (or industry, group, etc) to generate the total number of issues with RSI(2) over 90 > // Runs on ver 5.2 or higher and also generates a column with the RSI(2) value sorted from high to low > > RSI2_90 = RSI(2) > 90; > > Filter = 1; > > ADDCOLUMN( C, "LAST", 3.2, COLORYELLOW,COLORBLUE, 75) ; > ADDCOLUMN( RSI2_90 , "RSI(2) > 90" , 1.0 , COLORWHITE,COLORGREEN , 75); > ADDCOLUMN( RSI(2) , "RSI(2) " , 3.2, COLORDARKGREEN, COLORLIGHTGREY, 100 ); > > ADDSUMMARYROWS( 1, 1.0 , 4 ); > SETSORTCOLUMNS( -4, -5 ) ; > > > > > ----- Original Message ----- > From: bistrader > To: [email protected] > Sent: Friday, January 08, 2010 10:48 AM > Subject: [amibroker] Re: RSI(2) and AddToComposite > > > I believe you could also start with something like the following, with your rsi code added, and do via regular bactest, plot or whatever. > > function CountWatchList( listnum ) > { > // retrive comma-separated list of symbols in watch list > list = CategoryGetSymbols( categoryWatchlist, listnum ); > > Count = 0; // just in case there are no watch list members > > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ ) > { > Count = Count + 1; > } > return Count; > } > > Count = CountWatchList(10); > //Filter = 1; > //AddColumn(Count, "Count", 5.3); > //Plot or whatever here > > > > --- In [email protected], "woodshedder_blogspot" <woodshedder_blogspot@> wrote: > > > > Wern, I think this will work for you. You'll need to use the scan feature. It is also going to compute a universe count for you as well. You can of course tweak the universe parameters any way you like. > > > > Regards, > > Wood > > > > Buy = Sell = 0; > > Universe = 0; > > RSI2Count = 0; > > AV10=MA(V,10); > > RSI2=RSI(2); > > > > // Scan and Count Universe > > for (i=1; i<BarCount; i++) > > { > > if (C[i]>1 AND AV10[i]>100000) > > Universe[i] = Universe[i] + 1; > > } > > AddToComposite (Universe, "~Universe", "X"); > > Plot ( Foreign("~Universe", "X"), "Universe",6,1); > > > > // Scan and Count RSI2 > 90 > > for (i=1; i<BarCount; i++) > > { > > if (C[i]>1 AND AV10[i]>100000 AND RSI2>90) > > RSI2Count[i] = RSI2Count[i] + 1; > > } > > AddToComposite (RSI2Count, "~RSI2Count", "X"); > > Plot ( Foreign("~RSI2Count", "X"), "RSI2Count",6,1); > > > > --- In [email protected], "wernkra" <WKRAG@> wrote: > > > > > > Hi there, > > > > > > is there a way to count the number of stocks which are at a certain RSI(2) threshold? > > > I'd like to plot the number of stocks with RSI(2) > 90. > > > > > > I guess that could be done with AddtoComposite. > > > > > > How would I do that? > > > > > > Thanks. > > > > > > Wern > > > > > > > > > > ------------------------------------ > > **** 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
