PureBytes Links
Trading Reference Links
|
This is a whole lot better than starting from scrath. Thanks Dingo.
--- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@xxxx> wrote:
> I don't know your background but perhaps the following scripts can
be
> combined to do what you want:
>
> -----------jScript for batch backtesting Msg 30065
> /*****************************
> *
> * BatchTest.js
> *
> * Batch testing sample script
> * Shows how to use JScript and new AmiBroker 4.23
> * 'Analysis' object to perform batch backtesting
> * and generate reports
> *
> * Created: Dec 21, 2002 TJ
> * Last modification: Dec 22, 2002 TJ
> *
> * Copyright (C)2002 Amibroker.com
> *
> * Status: Freeware
> * You can use/modify/adopt this code freely
> *
> */
>
> /* The directory where AFL files are stored
> ** Also reports generated by the bactest
> ** will be saved here
> */
>
> AFLFolder = "C:\\Program Files\\AmiBroker\\AFL"; // MODIFY TO FIT
YOUR
> SETUP
>
> WScript.Echo("Batch testing of all AFL files stored in " +
AFLFolder );
>
> var AB, AA;
> var fso, f, f1, fc, s;
> var filename;
>
> /* Create AmiBroker object and get Analysis object */
>
> AB = new ActiveXObject("Broker.Application");
> AA = AB.Analysis;
>
> /* backtest over symbols and all quotes*/
> AA.ClearFilters();
> AA.ApplyTo = 0; // use symbols
> AA.RangeMode = 0; // all quotes
>
> /* to use filters you should uncomment lines below
>
> // AA.ApplyTo = 2; // use filters
> // AA.Filter(0,"watchlist") = 2 /* watch list number */;
> // AA.Filter(0,"group") = 0 /* group number */;
>
>
> /* Create FileSystemObject */
> fso = new ActiveXObject("Scripting.FileSystemObject");
>
> /* Iterate through all files in the folder */
> f = fso.GetFolder(AFLFolder);
> fc = new Enumerator(f.files);
> for (; !fc.atEnd(); fc.moveNext())
> {
> // we need to add empty string to make sure that filename is a
> string object
> filename = "" + fc.item();
>
> /* check the AFL extension */
> if( filename.substr( filename.length - 4 ).toUpperCase()
== ".AFL" )
> {
> if( AA.LoadFormula( filename ) )
> {
> AA.Backtest();
>
> reportname = filename.substr( 0, filename.length - 3 )
+ "HTML" ;
>
> AA.Report( reportname ); // generate report
> }
> }
> }
>
> WScript.Echo("Batch backtest finished");
>
>
>
> -----------jScript for building a watch list Msg 14290
>
> var filename;
> var fso, f, r;
> var ForReading = 1;
> var AmiBroker;
> var fields;
> var stocks;
> AmiBroker= new ActiveXObject("Broker.Application");
> fso= new ActiveXObject("Scripting.FileSystemObject");
>
> filename="wl0.txt";
> f = fso.OpenTextFile(filename, ForReading);
> while(!f.AtEndOfStream)
> {
> r=f.ReadLine();
> fields=r.split(";");
> stock=AmiBroker.Stocks.Add(fields[0]);
> stock.WatchListBits = stock.WatchListBits | ( 1 << 0 );
> }
> filename="wl1.txt";
> f = fso.OpenTextFile(filename, ForReading);
> while(!f.AtEndOfStream)
> {
> r=f.ReadLine();
> fields=r.split(";");
> stock=AmiBroker.Stocks.Add(fields[0]);
> stock.WatchListBits = stock.WatchListBits | ( 1 << 1 );
> }
>
> filename="wl2.txt";
> f = fso.OpenTextFile(filename, ForReading);
> while(!f.AtEndOfStream)
> {
> r=f.ReadLine();
> fields=r.split(";");
> stock=AmiBroker.Stocks.Add(fields[0]);
> stock.WatchListBits = stock.WatchListBits | ( 1 << 2 );
> }
>
> ... repeat for each watchlist ...
>
> AmiBroker.RefreshAll();
>
> --------------------------------------------------------------------
----
> -----
>
>
> -----------jScript for building a watch list Msg 2509
> /*
> ** File: Copy Ticker list to Group 10 List
> ** Created: Brett Forrester, June 09, 2001
> ** Purpose: Assign Tickers to Group List 10 in lieu of Watch List
> ** Language: JavaScript (Windows Scripting Host)
> **
> ** The data is stored in lines with following format
> ** <ticker>
> **
> */
>
> WScript.Echo( "Script Started" );
>
> /* change this line according to your data file name */
> ImportStocks("ZacksTop.csv");
>
> WScript.Echo( "Finished" );
>
> function ImportStocks( filename )
> {
> var fso, f, r;
> var ForReading = 1;
> var AmiBroker;
> var fields;
> var stock;
>
>
> /* Create AmiBroker app object */
> AmiBroker = new ActiveXObject( "Broker.Application" );
>
> /* ... and file system object */
> fso = new ActiveXObject( "Scripting.FileSystemObject" );
>
> /* open ASCII file */
> f = fso.OpenTextFile( filename, ForReading);
>
> i = 1;
> /* read the file line by line */
> while ( !f.AtEndOfStream )
> {
> r = f.ReadLine();
>
> /* split the lines using comma as a separator */
> fields = r.split(",");
>
> try
> {
>
> /* add a ticker - this is safe operation, in
> case that */
> /* ticker already exists, AmiBroker returns
> existing one */
> stock = AmiBroker.Stocks.Add( fields[ 0 ] );
>
> /* This line assigns the stock to Watch List
> 0 */
> stock.GroupID = 10;
>
> }
> catch( e )
> {
> WScript.echo( "There is a problem in
> line no." + i + ".\nThe line looks as follows:\n'" + r + "'\nIt
will
> be skipped and next lines will be processed as normal" );
> }
>
> i++;
> }
>
> /* refresh ticker list and windows */
> AmiBroker.RefreshAll();
>
> }
>
>
> -----Original Message-----
> From: adrian_gearing [mailto:aj_ent@x...]
> Sent: Saturday, March 08, 2003 12:35 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Automating Scans & Watchlists
>
>
> Hi,
> I'm fairly new to Amibroker and am looking for some advice.
>
> I have multiple scans that I run each day and copy the results from
> each scan into a different watchlist. I would like to automate
this
> process if possible to cut down the time involved.
>
> If anyone has any pointers on how to go about starting or has code
> that does something similar I would be most appreciative for your
> help.
>
> Thanks,
> Adrian Gearing.
>
>
>
> Yahoo! Groups Sponsor
>
> ADVERTISEMENT
>
>
<http://rd.yahoo.com/M=243066.2784921.4151384.1927555/D=egroupweb/S=17
05
> 632198:HM/A=1377502/R=0/*http://www.verisign.com/cgi-bin/go.cgi?
a=b31550
> 113206004000>
>
> <http://us.adserver.yahoo.com/l?
M=243066.2784921.4151384.1927555/D=egrou
> pmail/S=:HM/A=1377502/rand=505849600>
>
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/> .
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|