Remove the affected quotes and then Backfill again. There is always a second chance!
In AmiBroker select a Watchlist and store only the affected symbols whose quotes are needs to be deleted. Open a Notepad > Copy the below code and Paste it in the Notepad > Save it anywhere safe with a filename as you wish but with .js extension > Before you run this JavaScript, you need to make changes to the following variables:
1. filespec: Specify the path to the Watchlist of the affected symbols
2. DataDir: Specify the path to your Database
3. DeleteFrom: DateTime from which to Delete
4. DeleteTo: DateTime until which to Delete
Caution Do not change the DateTime format of DeleteFrom and DeleteTo. Just modify that is required to be modified. And DeleteTo must be always greater than DeleteFrom. Also Backup your DB before running the Script.
JavaScript:
//Before running the script, backup of the database is necessary to avoid any unexpected dataloss
filespec = "C:/Program Files/AmiBroker/My_Database_Name/WatchLists/My_Watchlist_containing_the_ruined_symbols.tls";
DataDir = "C:\\Program Files\\AmiBroker\\My_Database_Name";
var fso, watchlist, s, ForReading;
ForReading = 1, ForWriting = 2, s = "";
fso = new ActiveXObject( "Scripting.FileSystemObject" );
watchlist = fso.OpenTextFile( filespec, ForReading, false );
var oAB = new ActiveXObject( "Broker.Application" );
oAB.LoadDatabase( DataDir );
Shell = new ActiveXObject("WScript.Shell");
var oStocks = oAB.Stocks;
var Qty = oStocks.Count;
var DeleteFrom = new Date("November 02, 2018 00:00:00");
var DeleteTo = new Date("November 02, 2018 23:59:59");
var DayDeleteFromNum = Date.parse(DeleteFrom);
var DayDeleteToNum = Date.parse(DeleteTo);
file = fso.OpenTextFile( "_remowe_xdays.log", ForWriting, true );
file.WriteLine( "Starting delete quotes from date:" + DeleteFrom);
file.WriteLine( "" );
while( !watchlist.AtEndOfStream )
{
s = watchlist.ReadLine( );
for( i = 0; i < Qty; i++ )
{
oStock = oStocks( i );
if( s == oStock.Ticker )
{
file.Write( i + ". " + oStock.Ticker + "=" );
for ( j = oStock.Quotations.Count - 1; j >= 0; j-- )
{
tmpDateNum = Date.parse( oStock.Quotations( j ).Date );
if(tmpDateNum >= DayDeleteFromNum)
{
if (tmpDateNum <= DayDeleteToNum)
{
oStock.Quotations.Remove( j );
}
}
else
{
break;
}
}
file.WriteLine( "OK" );
}
}
}
watchlist.Close( );
oAB.RefreshAll();
oAB.SaveDatabase( );
Shell.Popup( "Done!", 1.5 );