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

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


  • Date: Wed, 25 Nov 2009 10:48:23 -0600
  • From: "Joe Landry" <jelandry@xxxxxxxxxxxxx>
  • Subject: Re: [amibroker] EMPTY A WATCHLIST WITH JAVA SCRIPT QUESTION

PureBytes Links

Trading Reference Links



Hello Bert:  Unless you're really interested in working with jScript you can do clear and build without it.
Something I put together using Bruce's FT utilities.  As the instructions say, careful what your paramlist in the
Autoanalyzer function is set to, cause it will erase the number that resides there.
 
Joe
 
// Builds a watchlist from a FastTrack Family
// May 2005  JEL
// Uses the Bruce Robinson's utilities to get a family from the
// FastTrack data base
// Will look in C:\FT\FTDEF   in USERDEF and in FT4WIN for the family named
// in the parameter list below.
// Careful of what watchlist you point this to because it will empty it first
// then fill it with the FT Family
// How to Run in Autoanalyzer window
// 1) Set RANGE to LAST QUOTATIONS = 1
// 2) Set APPLY TO CURRENT SYMBOL a stock with lots of data bars/history a money market or XOM
// 3) Select PARAMETERS button and ENTER the Watchlist LIST you want to ERASE and REFILL
// 4) Select FastTrack Family   jerryall   or myfam  upper or lower case.
// 5) Press SCAN, to transfer the tickers from the FT FAM to the WATCHLIST of your choosing
#pragma nocache
#include <FT-Utilities8.afl>

script = GetScriptObject();
WLNum = Param("Watchlist Number",7,1,60,1);
FamName= ParamStr("FT Family Name","BD-Junk");  // Looks in FTDEF, USERDEF and FT4WIN
 
if ( Status("action") == 3 )

 // ****************  File Ops Clears and Rebuilds a Watchlist ********************
 
 currentlist    = CategoryGetSymbols( categoryWatchlist, WLNum );
 for (i = 0; (member = StrExtract(currentlist, i)) != ""; i++)
  CategoryRemoveSymbol( member, categoryWatchlist, WLNum );
 
 // **************** Get the FT Family **********************************************
 List = script.FTGetFam(FamName);  
 for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
 {
 CategoryAddSymbol(sym,categoryWatchlist,WLNUM);
 }
 
 Buy=Sell=0;  // this fakes out the AmiBroker AutoAnalyzer
 //           and lets you run the program without an error indication.
}
 
 
----- Original Message -----
From: bistrader
Sent: Wednesday, November 25, 2009 9:29 AM
Subject: [amibroker] EMPTY A WATCHLIST WITH _javascript_ QUESTION

 

I am working on a _javascript_ 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 _javascript_ 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___