[FONT="Courier New"]
// // //
// // File: DeleteDateRange.js //
// // Author: mastermind007 //
// // http://www.traderji.com/amibroker/88211-deleting-rt-ticks-2.html#post825413
// // Purpose: Remove all quotations between //
// // two given Date and Time Stamps //
// // Language: JScript (Windows Scripting Host) //
// // ENJOY :-) //
// // //
// ////////////////////////////////////////////////////////////////////
//A D J U S T N E X T 3 L I N E S B E F O R E R U N N I N G
// ////////////////////////////////////////////////////////////////////
DataDir = "@@@@@YOURDATA@@@PATH"
// CAUTION Jan is 00. Feb is 01. Dec is 11.
var DayDeleteFrom = new Date(2013, 00, 07, 09, 00);
var DayDeleteUpto = new Date(2013, 00, 07, 23, 30);
// ///////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////
var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileX = fso.OpenTextFile( "C:\\DeleteDateRange.Amibroker.log", 2, true );
oAB.LoadDatabase( DataDir );
var oStocks = oAB.Stocks;
var Qty = oStocks.Count;
var j = 0;
var k = 0;
fileX.WriteLine( "Will delete all quotations from all stocks between starting date:" + DayDeleteFrom);
fileX.WriteLine( "and ending date:" + DayDeleteUpto);
fileX.WriteLine( "" );
WScript.Echo("Cleanup Will Start Now !!!. Abort Process if this is not what you want" );
for( i = 0; i < Qty; i++ )
{
k = 0;
oStock = oStocks( i );
fileX.Write( i + ". " + oStock.Ticker + "=" );
while (j < oStock.Quotations.Count)
{
tmpDateNum = oStock.Quotations( j ).Date ;
//fileX.WriteLine( "Date returned by AB is " + tmpDateNum);
if ((tmpDateNum >= DayDeleteFrom) && (tmpDateNum <= DayDeleteUpto))
{
k++;
oStock.Quotations.Remove(j);
} else if (tmpDateNum > DayDeleteUpto)
{
break;
} else
j++;
}
fileX.WriteLine( "Deleted " + k + " quotes from " + oStock.Ticker);
}
oAB.SaveDatabase( );
fileX.Close();
WScript.Echo("Deletion completed :-)" );
[/FONT]