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

RE: [amibroker] Automating Scans & Watchlists



PureBytes Links

Trading Reference Links




I 
don't know your background but perhaps the following scripts can be combined to 
do what you want:
<FONT face=Tahoma color=#0000ff 
size=2> 
<FONT face=Tahoma color=#0000ff 
size=2>-----------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*/
 
<FONT face=Tahoma color=#0000ff 
size=2>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 
symbolsAA.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");
 
<FONT face=Tahoma color=#0000ff 
size=2> 
 
<FONT face=Tahoma color=#0000ff 
size=2>-----------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(); ----------------------------------------------------------------------------- 
 
<FONT face=Tahoma color=#0000ff 
size=2>-----------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();  }

  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: adrian_gearing 
  [mailto:aj_ent@xxxxxxxxxxx] Sent: Saturday, March 08, 2003 12:35 
  AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] 
  Automating Scans & WatchlistsHi,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.Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT









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 the Yahoo! Terms of Service.