The ultimate porfolio management solution.
For Portfolio Manager Click Here
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
#1 Selling Amibroker Plugin featuring:
Find Out More Here
Advanced Adaptive Indicators
Advanced Pattern Exploration
And Much More ....
remove data, amibroker, jscript
Many times there is bad data uploaded into the database due to various reasons and then there is no other solution but to create a new database.
Understanding the common difficulty faced by amibroker users all across , this is a one stop solution wherein you can delete a particular date’s or range of date’s data from a particular amibroker database. All you have to do is supply name of database and range date and time (in case of intraday data) and run the jscript file from the “command prompt”. This script works for both EOD and intraday data. Its not my script and I am just the medium.
almost 6 years ago
over 8 years ago
Copy & Paste Friendly
/* Its a jscript and hence should be run from the command prompt. Change parameters ** before executing the script. Also take backup of your data for safety reasons.
** AmiBroker/Win32 scripting Example
** File: Remove all quotations between dates .js
** Version: 0.1 beta
** Purpose: Remove all quotations between dates for all symbols !
** Language: JScript (Windows Scripting Host)
** CHANGE variable DataDir
** CHANGE variable DeleteFrom and DeleteTo
** ENJOY :-)
// where database is stored
fs = new ActiveXObject("Scripting.FileSystemObject");
DataDir = "c:\\Program Files\\AmiBroker\\Data"
var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
file = fso.OpenTextFile( "_remowe_xdays.log", 2, true );
oAB.LoadDatabase( DataDir );
var oStocks = oAB.Stocks;
var Qty = oStocks.Count;
var MiliSecInDay = 24 * 60 * 60 *1000;
var DeleteFrom = new Date("august 1, 2009 00:00:00");
var DeleteTo = new Date("august 15, 2009 00:00:00");
//add a day to the date
DeleteTo.setDate(DeleteTo.getDate() + 1);
// make date with time 00:00:00
var DayDeleteFrom = new Date((Math.floor(DeleteFrom / MiliSecInDay)) * MiliSecInDay);
var DayDeleteFromNum = (Math.floor(DeleteFrom / MiliSecInDay)) * MiliSecInDay;
var DayDeleteTo = new Date((Math.floor(DeleteTo / MiliSecInDay)) * MiliSecInDay);
var DayDeleteToNum = (Math.floor(DeleteTo / MiliSecInDay)) * MiliSecInDay;
file.WriteLine( "Starting delete quotes from date:" + DeleteFrom);
file.WriteLine( "" );
for( i = 0; i < Qty; i++ )
oStock = oStocks( i );
file.Write( i + ". " + oStock.Ticker + "=" );
//file.Write( "j=" + j + "," );
//tmpDate = new Date( oStock.Quotations( j ).Date );
tmpDateNum = oStock.Quotations( j ).Date ;
if (tmpDateNum >= DayDeleteFromNum)
if (tmpDateNum <= DayDeleteToNum)
//file.WriteLine( "Delete data=" + tmpDateNum);
//file.WriteLine( "Last data no to delete=" +tmpDateNum);
file.WriteLine( "OK" );
WScript.Echo("Cleanup ended :-)" );
Please login here to leave a comment.