This might work. After running the scan, you would have to import the new
file.
y = Year();
m = Month();
d = Day();
Hr = Hour();
Mn = Minute();
Sc = Second();
fh = fopen("adj_data.txt","w");
for( i = 0; i < BarCount; i++ ) {
ds = StrFormat("%4g-%02g-%02g,",y[i], m[i], d[i] ); //date
ts = StrFormat("%02g:%02g:%02g",Hr[i], Mn[i], Sc[i]); //time
qs = StrFormat(" %.2f, %.2f, %.2f, %.2f, %g", H[i], L[i], O[i], C[i], V[i]
); //data
if (Hr[i] || Mn[i] || Sc[i]) {
fputs ("\n"+Name()+", ",fh);
fputs( ds, fh );
fputs( ts, fh );
fputs( qs, fh); }
}
fclose( fh );
Buy = 0;
-------------------------------------------
On Sun, Sep 21, 2008 at 12:59 PM, Barry Scarborough
<[EMAIL PROTECTED]>wrote:
> 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." );
>
>
>