Import ASCII only for specified fields?

Hello,

Is it possible to do 'File -> Import ASCII'
to modify only specified fields?

For example,
I have a symbol with full-filled quote data,
for some reason I need to modify only Close, Volume, Aux1, Aux2,
but not change all other values (such as Open, High, Low), so:

Step1. I create a *.format as below:

$FORMAT Ticker, Date_YMD, Close, Volume, Aux1, Aux2, Skip
$SKIPLINES 1
$SEPARATOR ,
$AUTOADD 1
$OVERWRITE 1
$CONT 1
$DEBUG 1

Step2. I did 'File -> Import ASCII'
to import a file with above format.

The result is,
all Price fields are overwritten by imported Close price,
even Open, High, Low are also modified to imported Close price,

all Volume are imported but
some little difference with imported Volume
for example,
imported Volume should be 156789012,
but I see 156789008 on Quote Editor.

Could anyone please help me
to prevent modify non-specified fields
such as Open, High, Low,
when I use 'File -> Import ASCII' ?

Thank you very much :slightly_smiling_face: !

Take a look at $HYBRID import mode
https://www.amibroker.com/kb/2014/10/14/how-to-combine-data/

3 Likes

@fxshrat,
You did real help, thanks for your instruction!
I've applied $HYBRID, then all other price field keey their values!

but one remain problem is,
my old volume data cannot be overwritten,
I found it has never been modified (after import ASCII).

old data as follows:
image

imported data as follows:

image
My final problem is, I cannot modify Volume
via 'Import ASCII', Please help!

Hybrid mode as it name says, is meant to COMBINE data. It was originally designed to "ADD" or "Augment" quotes already existing in the database. So if you import high using $HYBRID mode and high in the file is higher than high in your existing database it will adjust high, but if imported value is lower than existing high, it won't be changed. If you import volume using $HYBRID mode, it will be ADDED to what is already existing in the database.

3 Likes

@Tomasz,

Is there a way to clear all volume of a symbol (or symbols)?
so I can clear all volume,
then import updated (or say correct) volume data with $HYBRID 1.

Thanks you very much for your instructions :smiley: !

One possible way:

  1. Create a composite of your symbol leaving out Volume. Composite name e.g. "~Copy_"+Name()
  2. Import update to that composite symbol(s)
  3. Check if all is OK
  4. Erase old symbol(s) from DB at once (e.g. if they are in a Watchlist)
  5. Rename composite symbol(s) (e.g. via OLE if it is multiple symbols) by removing/replacing "~Copy_" from composite name.
1 Like

Another way

  1. Create exploration with Name,O,H,L,C,V,OI,Aux1,Aux2
  2. Volume column for that exploration being zero -> AddColumn(0,"Volume", 1);
  3. Choose symbols to output via "Current" or "Filter"
  4. Click Explore button
  5. After exploration being finished save result list to file via File - Export HTML/CSV...
  6. Re-import that data to your DB standard way
  7. Volume should be zero after import

A third (possibly slow) way
Rewrite 3rd script of this link to set qt.Volume to zero instead of removing quotes.

2 Likes

You can use script like this:

// WARNING - running this formula would set volume to ZERO for given symbol 
// (in this sample "AA")
function RemoveAllVolume( symbol )
{
    AB = CreateObject("Broker.Application");
    Stk = AB.Stocks( symbol );
    Quotes = Stk.Quotations;
    iQty = Quotes.Count;
    for( i =0 ; i < iQty; i++ )
    {
       qt = Quotes.Item(i);
       qt.Volume = 0;
    }
    AB.RefreshAll();
}
RemoveAllVolume("AA"); // if you change it to RemoveAlLVolume(Name()); it would work for any/all symbols
printf( "Completed" );
4 Likes