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

[amibroker] Re: EMPTY A WATCHLIST WITH JAVA SCRIPT QUESTION


  • Date: Wed, 25 Nov 2009 20:53:28 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: EMPTY A WATCHLIST WITH JAVA SCRIPT QUESTION

PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "bistrader" <bistrader@xxx> 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.
>




------------------------------------

**** 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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/