qitrader
04-01-2007, 12:32 PM
For those of you using Amibroker to gather data from YAHOO Historical database, I found that the following code helps export their data into ASCII so it can be easily recognized by MTpredictor EOD.
Here is the code for AB and must be copy in the Amibroker directory under Formulas.
/*
Export intraday and EOD data to TXT files
One file for each stock
In the first line insert the directory you want to save them to, make sure the directory exists
Select your charts to export with the "Apply to" filter in AA window
Select the timeframe period you want to save as using the AA "Settings"
Press Scan button
by Graham Kavanagh 05 Feb 2004
*/
fh = fopen( "c:\\Temp\\"+Name()+".txt", "w");
if( fh )
{
fputs( "Date,Time,Open,High,Low,Close,Volume \n", fh );
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
n = Second();
for( i = 0; i < BarCount; i++ )
{
//fputs( Name() + "," , fh );
ds = StrFormat("%02.0f%02.0f%02.0f,",
y[ i ], m[ i ], d[ i ] );
fputs( ds, fh );
ts = StrFormat("%02.0f:%02.0f:%02.0f,",
r[ i ],e[ i ],n[ i ] );
fputs( ts, fh );
qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n",
O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
fputs( qs, fh );
}
fclose( fh );
}
/////////////////////////////////////////////
After this is done, then use Mtpredictor EOD to define the data. You will now have over 7000 stocks in the database. Or you can filter the stocks in Amibroker first by using my filtering criteria. This will filter stocks with Today 's volume > 1 Million, ATR > 1 and average 30 day volume > 500,000.
Price = Param ( " Price ", 25, 10, 1000, 5 ) ;
Today_Vol = Param ( " Today's Volume ", 1000, 100, 150000000, 1000 ) ;
AvgVol = Param ( " Average Volume ", 500, 100, 150000000, 1000 ) ;
ATRvalue = Param ( " ATR ", 1, .5, 5, .1 ) ;
Myfilter = Close > Price AND V >= Today_Vol AND EMA (V, 30) >= AvgVol AND abs (O-C) >= ATRvalue ;
//if( LastValue ( myfilter ) )
//{
//CategoryAddSymbol( "", categoryWatchlist, 0 );
//}
Filter = Myfilter ;
Buy=0;
AddColumn (C, "Close");
Hope this helps,
Here is the code for AB and must be copy in the Amibroker directory under Formulas.
/*
Export intraday and EOD data to TXT files
One file for each stock
In the first line insert the directory you want to save them to, make sure the directory exists
Select your charts to export with the "Apply to" filter in AA window
Select the timeframe period you want to save as using the AA "Settings"
Press Scan button
by Graham Kavanagh 05 Feb 2004
*/
fh = fopen( "c:\\Temp\\"+Name()+".txt", "w");
if( fh )
{
fputs( "Date,Time,Open,High,Low,Close,Volume \n", fh );
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
n = Second();
for( i = 0; i < BarCount; i++ )
{
//fputs( Name() + "," , fh );
ds = StrFormat("%02.0f%02.0f%02.0f,",
y[ i ], m[ i ], d[ i ] );
fputs( ds, fh );
ts = StrFormat("%02.0f:%02.0f:%02.0f,",
r[ i ],e[ i ],n[ i ] );
fputs( ts, fh );
qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n",
O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
fputs( qs, fh );
}
fclose( fh );
}
/////////////////////////////////////////////
After this is done, then use Mtpredictor EOD to define the data. You will now have over 7000 stocks in the database. Or you can filter the stocks in Amibroker first by using my filtering criteria. This will filter stocks with Today 's volume > 1 Million, ATR > 1 and average 30 day volume > 500,000.
Price = Param ( " Price ", 25, 10, 1000, 5 ) ;
Today_Vol = Param ( " Today's Volume ", 1000, 100, 150000000, 1000 ) ;
AvgVol = Param ( " Average Volume ", 500, 100, 150000000, 1000 ) ;
ATRvalue = Param ( " ATR ", 1, .5, 5, .1 ) ;
Myfilter = Close > Price AND V >= Today_Vol AND EMA (V, 30) >= AvgVol AND abs (O-C) >= ATRvalue ;
//if( LastValue ( myfilter ) )
//{
//CategoryAddSymbol( "", categoryWatchlist, 0 );
//}
Filter = Myfilter ;
Buy=0;
AddColumn (C, "Close");
Hope this helps,