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

[amibroker] HERE IS JAVA SCRIPT EXPLORATION AND EXPORT EXAMPLE


  • Date: Tue, 24 Nov 2009 15:56:26 -0000
  • From: "bistrader" <bistrader@xxxxxxxxx>
  • Subject: [amibroker] HERE IS JAVA SCRIPT EXPLORATION AND EXPORT EXAMPLE

PureBytes Links

Trading Reference Links

Mike, Herman and others,
Here is my Java Script to run an Exploration and then Export it to a csv file.  This was the easy one.

// Exploration_Example.js

//  This Java Script file should:
//  1. Load a Database
//  2. Run an exploration on an afl.
//  3. Exports the exploration to a csv file.

// ----------------------------------------------------------------------------
// 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\\US-Stocks");

// ----------------------------------------------------------------------------
// Automatic Analysis Input and Export Information
// ----------------------------------------------------------------------------
AFL_Directory = "C:\\Amibroker\\Temp\\";                 // Location of AFL
AFL_ExploreFileName = "Exploration_Example.afl";         // AFL program to get the data to be exported
AFL_ExploreFile = AFL_Directory + AFL_ExploreFileName;   // Name of the above program with it's path included

Export_Directory = "C:\\Amibroker\\Temp\\";              // Location where Exported data will be saved
ExportFileName = "Exploration_Example.csv";              // Name of export file
ExportFile = Export_Directory + ExportFileName;          // Name of above export file with its path included

Settings_Directory = "C:\\AmiBroker\\Settings\\";
SettingsFileName = "SettingsBasic.ABS";
SettingsFile = Settings_Directory + SettingsFileName;

// ----------------------------------------------------------------------------
// Load Reference Ticker into AmiBroker
// ----------------------------------------------------------------------------
AB.ActiveDocument.Name = "RUT-I"; // Set RUT-I as reference ticker

// ----------------------------------------------------------------------------
// Automatic Analysis - Setup Exploration using info defined above
// ----------------------------------------------------------------------------
AA.LoadSettings( SettingsFile );
AA.LoadFormula( AFL_ExploreFile );

// Use the following to tell Amibroker what to Include/Exclude and what dates to use
//
// "index", "favorite", "market", "group", "sector", "index", "watchlist"
// 0 = include; 1 = exclude
// 0 = all stocks, 1 = current stock, 2 = use filter
// 0 = all quotes, 1 = n last quotes, 2 = n last days, 3 = from-to date
//

// Set Filters
AA.ClearFilters();

// AA.Filter(0,"favorite") = 1;   // Try this to load a long ticker which is favorites ^rut
AA.ApplyTo = 1;                   // 0 = all stocks, 1 = current stock, 2 = use filter
//AA.Filter(0,"watchlist") = 0;     // 0 = Include; "watchlist" number

// Set Dates
AA.RangeMode = 3;                    // 0 = all quotes, 1 = n last quotes, 2 = n last days, 3 = from-to date
//AA.RangeN = 5000;
AA.RangeFromDate = "12/31/2002";
AA.RangeToDate = "12/31/2099";

// ----------------------------------------------------------------------------
// Run exploration, export exploration to csv file
// ----------------------------------------------------------------------------
AA.Explore();
        
AA.Export( ExportFile );

// ----------------------------------------------------------------------------
// Save database (not really needed), Refresh database (also not really needed
// and close AA window when done.
// ----------------------------------------------------------------------------
AB.SaveDatabase();
AB.RefreshAll();

AA.ShowWindow(0);                     // 0 = all stocks, 1 = current stock, 2 = use filter

// ----------------------------------------------------------------------------



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

**** 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/