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

[amibroker] Convert script to ALF



PureBytes Links

Trading Reference Links

I wrote the following script to delete daily data bars in an intraday 
database. Scripts really run slow, like many hours, and I was 
wondering if this could be coded in AFL and run as a Scan. I run a 
scan to export all intraday data and it takes a few minutes while the 
script runs for hours and hours.

I just want to know if I can delete daily bars using an AFL formula 
in Analysis>Scan using the object model, or some other way.

Thanks,
Barry

/*
** AmiBroker/Win32 Scripting Program
**
** File:  DeleteDailyInIntraday.js
** Created:  Barry Scarboroughm Feb 23, 2007
** Purpose:  Cleanup the database when daily data is in the intraday 
database.
** Language:   JScript (Windows Scripting Host)
*/
 
var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var Shell = new ActiveXObject("WScript.Shell");
var oStocks = oAB.Stocks;
var numStocks  = oStocks.Count;
var oStocksToDelete = new Array;

WScript.Echo("Deleting daily data in intraday database. " );

for( i = 0; i < numStocks;  i++ )
{
	oStock = oStocks( i );
	var qty = oStock.Quotations.Count;
	for(j = 0; j < qty; j++)
	{
	    oQuote = oStock.Quotations( j );
	    var oDate = new Date( oQuote.Date ); // create date object
	    hour = oDate.getHours();
	    min  = oDate.getMinutes();
	    sec  = oDate.getSeconds();
	    if (hour == "0" && min == "0" && sec == "0" )
	    {
		     oQuote.Remove; 
	    }
  }
}

 oAB.RefreshAll();

WScript.Echo("Finished deleting daily data in intraday database." );


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

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/