{"id":1093,"date":"2015-01-29T18:45:08","date_gmt":"2015-01-29T23:45:08","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=1093"},"modified":"2015-02-11T19:01:50","modified_gmt":"2015-02-12T00:01:50","slug":"importing-auxilliary-data-into-amibroker-database","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2015\/01\/29\/importing-auxilliary-data-into-amibroker-database\/","title":{"rendered":"Importing auxilliary data into AmiBroker database"},"content":{"rendered":"
AmiBroker database structure offers the following fields: Open, High, Low, Close, Volume, OpenInt, Aux1, Aux2. The last two fields, i.e. Aux1<\/strong> and Aux2<\/strong> are meant for storing any custom historical data-arrays we may need.<\/p> Pretty often, we already have quotations data present in the database and we just want to put some extra data into auxiliary fields. To combine existing data with imported data, we can need to use hybrid mode. In the Import Wizard<\/a> just add this command in “Additional commands’ field.<\/p> Hybrid mode works so that with each imported record it looks for matching record in the database and it combines existing data with data being imported. If OHLC prices are not provided in the imported file you need to specify $ALLOWNEG 1 option. Otherwise you would get error messages about missing close price.<\/p> Auxiliary data fields can then be read using simply Aux1<\/strong> and Aux2<\/strong> identifiers:<\/p> However – if two additional fields are not enough for our purposes, we can also import quotes into some synthetic tickers and have another set of OHLC, V, OI, Aux1 and Aux2 fields available for importing. Synthetic ticker in this context means just a custom symbol name that’s used just for storing such extra data. So – instead of importing additional arrays into IBM ticker or AAPL ticker, we could use for example IBM_extra and AAPL_extra symbols and their fields.<\/p> Using such common naming pattern (i.e. identical ‘_extra’ suffix with the original ticker name) will be useful, because later on to access data from the selected field we could use just the following AFL call:<\/p> and this line will read value from Close<\/strong> field of the respective ‘extra’ ticker as we select IBM or AAPL.<\/p> An alternative way to store and handle several custom arrays would be to use SQL database, then we could use ODBC plugin to read such data. The documentation of ODBC plugin is available at:<\/p>\r# This example assumes that file has format: \r# Symbol, Year-Month-Day, auxiliary_data1, auxiliary_data2\r$FORMAT Name, Date_YMD, Aux1, Aux2\r$HYBRID 1\r$ALLOWNEG 1\r<\/pre>
Plot<\/span>( <\/span>Aux1<\/span>, <\/span>"Aux1"<\/span>, <\/span>colorRed <\/span>)<\/code>
myVal <\/span>= <\/span>Foreign<\/span>( <\/span>Name<\/span>() +<\/span>"_extra"<\/span>, <\/span>"C"<\/span>)<\/code>