PureBytes Links
Trading Reference Links
|
I forgot "local" declarations for "i" and "Ticker". There may be other errors/omissions. But, you get the idea ;)
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
>
> Hi,
>
> It appears that you are trying to traverse a list of symbols and return
> a subset of those that are found to also be in a reference symbol list.
>
> That being the case, a couple of observations that might be helpful:
>
> - It would be better if your function did not rely on variable
> declarations that were defined somewhere else (e.g. TickerCategory,
> TickerListNum, NumTickers, etc.). Consider having your function take
> arguments instead.
>
> - Are you sure that NumTickers is the correct number of symbols found in
> SymbolList? Given that you just fetched SymbolList, how did you know how
> many symbols were in the list? Looks like a possible indexing error
> here.
>
> - No need to repeatedly fetch the symbols for your reference list (i.e.
> CategoryGetSymbols( categoryWatchlist, 9 )), unless the list is being
> updated by another process behind your back, the value will not change
> between iterations of the loop.
>
> - No need to use IFF. Just use IF without the "==" operator. Any non
> zero value is considered to be true.
>
> - No need to include a check for (SP1500N100 == 1 AND Found == 1). Your
> function never changes SP1500N100, so don't bother checking for it over
> and over again. Either check the value before ever calling your function
> in the first place, else check the value once at the very start of your
> function and just return an empty string if it is false.
>
> - Your return value will have an extra "," at the end, which would be
> different than any other list of symbols fetched using AmiBroker
> functions. Better to use the same format as AmiBroker so that you can
> pass your result list to any function that takes an AmiBroker list.
>
> Keeping all the rest of your logic, your function might look something
> like this (untested):
>
> function GetSymbols2(TickerCategory, TickerListNum, ReferenceList) {
> local InList;
> local TickerList;
> local SymbolList;
>
> InList = "," + ReferenceList + ",";
> TickerList = "";
> SymbolList = CategoryGetSymbols( TickerCategory, TickerListNum );
>
> for (i = 0; (Ticker = StrExtract(SymbolList, i)) != ""; i++) {
> if (StrFind(InList, "," + Ticker + ",")) {
> if (i > 0) {
> TickerList += ",";
> }
>
> TickerList += Ticker;
> }
> }
>
> return TickerList;
> }
>
>
> Sample usage becomes:
>
> if (SP1500N100) {
> WL_SP1500N100 = CategoryGetSymbols(categoryWatchlist, 9);
> Duplicates = GetSymbols2(categoryWatchList, 1, WL_SP1500N100);
> }
>
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx, "gmorlosky" <gmorlosky@> wrote:
> >
> > Use this, which will locate the string in the watchlist:
> >
> > function GetSymbols()
> > {
> > TickerList = "";
> > SymbolList = CategoryGetSymbols(TickerCategory, TickerListNum);
> >
> > for(n = 0; n < NumTickers; n++)
> > {
> > Ticker = StrExtract(SymbolList,n);
> > WL_SP1500N100 = CategoryGetSymbols(categoryWatchlist, 9);
> > Found = 0;
> > Found = IIf(StrFind(","+WL_SP1500N100+",",","+Ticker+",") > 0, 1, 0);
> > if (SP1500N100 == 1 AND Found == 1 )
> > TickerList = TickerList + Ticker + ",";
> > }
> > return TickerList;
> > }
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "gmorlosky" gmorlosky@ wrote:
> > >
> > > I have this code and the middle line of the "IIF" statement keeps
> telling me it's the wrong argument ?
> > >
> > > function GetSymbols()
> > > {
> > > TickerList = "";
> > > SymbolList = CategoryGetSymbols(TickerCategory, TickerListNum);
> > >
> > > for(n = 0; n < NumTickers; n++)
> > > {
> > > Ticker = StrExtract(SymbolList,n);
> > > IIf (InWatchListName( "1_S&P 1500 N100" ), Ticker = Ticker, Ticker =
> "");
> > > TickerList = TickerList + Ticker + ",";
> > > }
> > > return TickerList;
> > > }
> > >
> >
>
------------------------------------
**** 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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|