Mike, I just responded to your other reply as I missed it for some reason. Thanks again for this. I will certainly use it!!
I will leave my post for help in creating an afl within JavaScript. I want to: (1) create an afl from within JavaScript; (2) feed to this something that changes like the watchlist number, a file name, a ticker name; (3) run an exploration on this afl; (4) delete this afl when done. Help with this will help me to do a bunch of stuff that I want to do in JavaScript. In time, I will be able to do this stuff better, but for now this "create an afl within JavaScript" will help a lot. --- In [email protected], "Mike" <sfclimb...@...> wrote: > > Bert, > > Did you not see my post to your earlier thread? I gave you a working solution > to simultaneously empty and populate the watchlist. Symbols not found in your > input .csv file are removed from the list while symbols that are found in > your .csv file are added to the list, all in a single loop. > > See posting http://finance.groups.yahoo.com/group/amibroker/message/144269 > > Mike > > --- In [email protected], "bistrader" <bistrader@> wrote: > > > > I am working on a Java Script and am taking one step at a time. I want > > this section of the js to empty a watchlist. I have googled a lot and have > > commands that are javascript and visual basic. This is my error, but I am > > learning. Here is what I have on this should so far. Help appreciated. > > > > // emptyWatchlist.js > > > > // This Java Script file should: > > // 1. Load a Database > > // 2. Call a function to empty a watchlist. This function ... > > // a. Creates an afl > > // b. Runs an exploration on this afl to empty watchlist 10. > > // THIS AFL DOES NOT WORK YET > > // > > ---------------------------------------------------------------------------- > > // Create AmiBroker object and get Analysis object > > // > > ---------------------------------------------------------------------------- > > var AB, AA, i; > > > > AB = new ActiveXObject("Broker.Application"); > > AA = AB.Analysis; > > > > // > > ---------------------------------------------------------------------------- > > // Load Database > > // > > ---------------------------------------------------------------------------- > > AB.LoadDatabase("C:\\Amibroker\\FastTrack"); > > > > // > > ---------------------------------------------------------------------------- > > // Load Reference Ticker into AmiBroker > > // > > ---------------------------------------------------------------------------- > > AB.ActiveDocument.Name = "RUT-I"; // Set RUT-I as reference ticker > > > > // > > ---------------------------------------------------------------------------- > > // Empty Watchlist 10 > > // > > ---------------------------------------------------------------------------- > > var WatchlistNumber = 10 > > > > WLEmpty_Directory = "C:\\Amibroker\\Temp\\"; > > WLEmpty_ExploreFileName = "Empty_Watchlist.afl"; > > WLEmpty_ExploreFile = WlEmpty_Directory + WLEmpty_ExploreFileName; > > > > emptyWatchlist.call(10); > > //Call emptyWatchlist; // does not work? > > > > // > > ---------------------------------------------------------------------------- > > // Afl Code to Empty a Watchlist > > // > > ---------------------------------------------------------------------------- > > var Emptya = "list = GetCategorySymbols( categoryWatchlist, ";// Add > > watchlist number later > > var Emptyb = " );"; // Use Chr(34) later to add quotes > > var Emptyc = "for( i = 0; ( sym = StrExtract( list, i ) ) != "; > > var Emptyd = "; i++ )"; > > var Emptye = "{"; > > var Emptyf = " CategoryRemoveSymbol(sym, categoryWatchlist, "; > > var Emptyg = " );"; > > var Emptyh = " Filter=1;"; > > var Emptyi = "}"; > > var Emptyj = "AddTextColumn(sym ,";// Use Chr(34) later to add quotes > > var Emptyk = "Ticker"; > > var Emptyl = ");"; > > > > // > > ---------------------------------------------------------------------------- > > // Function to create an afl that will Empty a Watchlist > > // > > ---------------------------------------------------------------------------- > > function emptyWatchlist > > { > > Dim bolResult > > Dim FrmlaFile > > > > var Result = WSH.popup("Emptying a Watchlist") > > > > var FrmlaFile = FS.CreateTextFile(WLEmpty_ExploreFile, True) > > > > With FrmlaFile > > .WriteLine Emptya + cstr(WatchlistNumber) + Emptyb > > .WriteLine Emptyc + Chr(34) + Chr(34) + Emptyd > > .WriteLine Emptye > > .WriteLine Emptyf + cstr(WatchlistNumber) + Emptyg > > .WriteLine Emptyh > > .WriteLine Emptyi > > .WriteLine Emptyj + Chr(34) + Emptyk + Chr(34) + Emptyl > > .Close > > End With > > > > Set FrmlaFile = Nothing > > > > With AA > > .ApplyTo = 1; > > .RangeMode = 2; > > .RangeN = 1; > > .ClearFilters(); > > .Filter(0, "watchlist") = WatchlistNumber > > bolResult = .LoadFormula(WLEmpty_ExploreFile) > > If bolResult Then > > .Explore(); > > End If > > End With > > > > AB.RefreshAll() > > > > //End function > > } > > > > // That is it. > > >
