Home
MetaLib documentation - Trading
Contents
1. REATUS 19 ISeRecoOEdS 19 IIT EUR 19 ROUNG ce EDITT 19 IsMetastockDiltectory a o a to n Eva RE o Eid da 19 iStartIndex oce sei decade se a 20 Security File Functions 22 ilk ie rte ftir e ia yt 20 CloSeSecuLlby d ree atid podra retire Ae ra cciis e 20 OpensSecurityByEil nalrie ERE NE UA 21 OpenSecurityByNatme eie enar ra EAR 21 OpenSecurityBySymbol 2 cpi rirferrexidalbrtiierava gere iiral 21 Page 2 of 59 MIEL 22 EE 22 23 SeekToBegin Void iioii etti RR A 24 2 renovare 24 TA 25 REFERRE 26 Other Properties CN E E E Esau PIT reeled 26 M 26 ML WENGE Interface MEWriter Properties AN 27 bDateExists hd cosh retur cu EE eye ds ERE ERE 27 EASIER 27 adim 27 jara TRITT 27 TM 27
2. ERSTER PERI TE 39 OpenSecurityByNatme eiecit rera rnt Ern ae ea dane canadian aM ERR Tene PEDIR 39 OpenSecurityBySymbol ennemis nnn 40 41 Slc EET 41 plac 41 Update Charts csccccccd secrete tucetcuisiedececuceneresvanceieabsuaunesceduenunsltweutesraledeenethechies reece 42 MLSecurityFinder Interface 42 MLSecurityFinder Functions emen enin nnne 43 0 43 FindNextSecurity nns 43 ILE 43 MESecurityFinder Properti8s zu exces tr 44 bDisplaySeatchDialOg i eorpore tr RIA Geet ede aaa aa ERE 44 bScanS bbDirectories 5 1 dirt Reels stein 44 hSearchDialO PP REEL 44 SEGFIIGNAMEC dm 44 SOCCNAMG e 45 sodas entedadcalde 45 sSearchDlalogiTitle 2 ferrei d rudi agededettens 45 Page 3 of 59 MLConverter Interface eere enr 2 AIQ2MetaStock e
3. Lr 27 sCopyrightStrilgs 27 SDIPEGCUOPY ee 28 EROR SERE 28 MEWriter FUNCtONS cedeedeescbia 28 ApperidIntraday Security ecce etre pex th Lk aeo 28 ApperndSec Lrity 2 e eee ioo b 29 a a mm 29 AppendDataRecArray wo ccsccciecdscebseadecececetdstehevekexedecedeccehsechesieutscsecetushstelenererst 31 32 charngePriceFields read A ER aea 33 changePriceFieldsIntraday eser cre eden nt m 34 CHANGESECUFILVRECON DEN EVO ME RE Sa RU DRE ARA EI DRIN 35 POR P 36 c EL 36 eene inne emen nennen enn nne 36 DeleteIntradaySecRecordEx emnes nemen senes 37 seen 37 DeleteSe CuritiesS cs cubes stead 38 eater tare 38 OpenbiFectOny ipe dE RO di sacaaedanescasetastees 39 OpensSecurityByFil nalrie
4. Object Microsoft ActiveX Data Object Mirrnsnft ActiveX Mata Ohiect MetaLib 4 9 3 Double click on the MetaLib 5 0 entry 4 The MetaLib entry will appear in the Selected Components list box 5 Click on OK VB NET example code Dim Reader As New METALIBLib MLReader Reader OpenDirectory C MetaStock Reader ReadMaster Display all securities that are stored in the MS directory While Reader iMaRecordsLeft gt 0 Debug WriteLine Reader sMaSecName Reader sMaSecSymbol Reader ReadMaster End While Reader CloseDirectory How to add MetaLib to your C C VS NET 2003 or VS NET 2005 Project 1 Click on Project gt Add Reference 2 The Add Reference dialog will appear Page 10 of 59 45 Add Reference 9 COM Projects Browse Recent Component Name Typelib Version Path z Macro Hierarchy Type Library 8 0 C Program Files Microsoft Visual Studio 8 Com Macro Hierarchy Type Library 70 c Program Files Microsoft Visual Studio NET 200 Macro Hierarchy Type Library 9 0 D Microsoft Visual Studio 9 0 Common7WDE ws Marquee OLE Control module 10 C Program Files Microsoft Office OFFICEL1 HT MCEMediaStatus 1 0 Type Library 1 0 C Program Files HP QuickPlay Kernel common L3 MediaCaptureControls 1 0 Type 1 0 C Program Files Roxio Roxio MyDVD Basic v9AM MediaSelector 1 0 T
5. You can order MetaLib online on http shareiti element5 com product html productid2199762 You can pay via credit card wire transfer cash or check Please follow the instructions on the website Benefits of Registering e No restrictions on the number of starts e No splashing screen at start up e Free technical support provided by email Questions usually answered same day How to use the Registration Key Private version When you start MetaLib following dialog will appear Page 56 of 59 Reminder This copy of MetaLib is available 20 days evaluation period IF you decide to continue using the program you need to register the program Please take a look at the help file or press the Buy now button For more details By registering the software you are able to continue using it legally and are supporting our efforts to continually develop innovative products to best serve your needs If you order via credit card you receive the fully registered version of MetaLib within 5 minutes Product price private version 59 95 EURO Product price commercial version 249 95 EURO Product price real time version 449 95 EURO You are on day 0 of 20 Enter Key Buy Now Click on the Enter key to enter your unlock key Commercial and Real time version It is necessary that you call the SetRegistrationInfo of the MLRegistration interface before you call any other function of MetaLib In t
6. sSecuritySymbols The symbol of the securities you want to delete Return Values The DeleteSecurities function can raise the following errors e File system errors ML SECURITY SYMBOL NOT FOUND 0 0642 1602 ML INVALID SYMBOL 0x064b 1611 For extended error descriptions go to the MetaLib error codes section DeleteSecRecord The DeleteSecRecord function removes a price record from a security price record file Fxxx dat or Fxxx mwd Before you can use the DeleteSecRecord function you must call one of the OpenSecurityBy functions HRESULT DeleteSecRecord int iDate Parameters iDate The date of the price record you want to delete Return Values The DeleteSecRecord function can raise the following errors e File system errors e ML DATE NOT FOUND 0 0644 1604 e ML FAILED TO DEL PRICE RECORD 0x0652 1618 For extended error descriptions go to the MetaLib error codes section Page 38 of 59 OpenDirectory The OpenDirectory function opens a directory that contains Master EMaster XMaster and security price record files Fxxx dat or Fxxx mwd The function returns the ML_ACCESS_DENIED 0x0674 1652 error if the directory is currently opened by MetaStock OpenDirectory BSTR sDirectory Parameters sDirectory The name of the directory that you want to open Return Values The OpenDirectory function can raise the following errors e File system errors e ML DIRECTORY NOT EXIST 0 0649
7. 1608 e ML ACCESS DENIED 0x0674 1652 For extended error descriptions go to the MetaLib error codes section OpenSecurityByFilename The OpenSecurityByFileName function opens the Fxxx xxx file specified in the sFileName parameter Use the AppendDataRec function to add price records to the specified file OpenSecurityByFilename BSTR sFileName Parameters sFileName The name of the file containing the security records EX C MetaStock Dow F1 dat Return Values The OpenSecurityByFilename function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Example This example appends a security record at the end of the C MetaStock Dow F1 dat file Dim Writer As New MLWriter Writer OpenSecurityByFilename C MetaStock Fl dat Writer AppendDataRec 20001021 0 23 12 24 11 21 02 24 2 0 0 Writer CloseDirectory OpenSecurityByName The OpenSecurityByNamefunction opens the Fx xxx file that contains the specified security name Use the AppendDataRec function to add price records to the specified file Before you can call this function you must call the OpenDirectory function Page 39 of 59 OpenSecurityByName BSTR sSecurityName Parameters sSecurityName The name of the security Note Security name is not case sensitive Return Values The OpenSecurityByName function can raise the following errors e File system errors e ML SECURITY NAME N
8. ReadDay MsgBox Reader iSeDate amp Chr 9 amp Reader dSeHigh amp Chr 9 _ amp Reader dSeLow amp Chr 9 amp Reader dSeClose Loop Reader CloseDirectory SeekToBegin void The SeekToBegin function sets the position of the file pointer to the beginning of the file To open a security file use the OpenSecurityBy functions No data is actually read during the seek HRESULT SeekToBegin void Parameters This function has no parameters Return Values The SeekToBegin function can raise the following errors e File system errors e ML_BAD_SEEK 0x067b 1659 For extended error descriptions go to the MetaLib error codes section SeekToDate The SeekToDate function repositions the pointer in a previously opened file to the specified date To open a security file use the OpenSecurityBy functions No data is actually read during the seek After you have called the Seek function you must use the ReadDay function to read records from the specified position HRESULT SeekToDate BSTR sDate Parameters sDate The date where to move the pointer The date must have the following format yyyymmdd Return Values The SeekToDate function can raise the following errors e File system errors Page 24 of 59 ML DATE NOT FOUND 0x0644 1604 ML BAD SEEK 0x067b 1659 For extended error descriptions go to the MetaLib error codes section Example This example reads all records starting from the date
9. VR Sra ER Riera 15 5 dene IRAE RISE ARR DRE NR RR SIR RR ER ARR RA RR RR Rr 15 iMaFirstDate 5 iter oe Rei o Ree RR ate pees SR DAP DER aa a a Ea OEE 15 iMabastDate eme SPARE REP ARIENDR REM 15 DER 15 MalintervVall TRI ITI TII TTE 15 MaPGnioGiGity ER 16 Master File Functions wh ev ak EYE e dae ge eor 16 CIOSEDIPECOY rem 16 DisplayMSDirBFOWSet ape Ti eea Ea 16 17 Re adMast6er rci cri mead ode Tea dui PRI lc esters 18 Security File Properties wi Jii opio curo rne Ia rap Ro 18 iSeADate ci PIN i 18 18 CS CAI E A 18 OS GALOW eng IE DAE A 18 mM 18 CIIM 19 nieht 19 m Te a REPRE TREO TITTEN THERETO 19 AS SHOW 19 dSeclose tertie em steams Savane SAP PAIS UNO DS RAD DM OT 19 dSeVolutmiga sia coser etos een Nux ANDREE 19 19 iSeRecotdsLeft
10. 0 Writer CloseDirectory Page 40 of 59 Sort The Sort function sorts the price records of the opened security HRESULT Sort void Return Values The Sort function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Example This example appends some price records to a security file and sorts them afterwards Dim Writer As New MLWriter Writer CreateDirectory C MetaStock Writer AppendSecurity MSFT Microsoft Daily Writer AppendDataRec 20001021 0 23 12 24 11 21 02 24 2 Writer AppendDataRec 20001020 0 23 12 24 11 21 02 24 2 Writer AppendDataRec 20001024 0 23 12 24 11 21 02 24 2 Writer AppendDataRec 19990920 0 23 12 24 11 21 02 24 2 Writer AppendDataRec 20100621 0 23 12 24 11 21 02 24 2 Writer AppendDataRec 19980101 0 23 12 24 11 21 02 24 2 Writer Sort Writer CloseDirectory After you have called the Sort function the dates will be stored in the following sequence 19980101 19990920 20001020 20001021 20001024 20100621 SortEx The SortEx function sorts the price records of the opened security It also removes duplicate records from the security price record file HRESULT SortEx void Return Values The SortEx function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Split The Split function is used to adjust the price data and volume for
11. 0x064f 1615 ChangePriceFields The ChangePriceFields function allows you to change a price record of a security price record file Fxxx dat or Fxxx mwd Before you can use the ChangePriceFields function you must call one of the OpenSecurityBy functions HRESULT ChangePriceFields int iDate int iNewDate int iNewTime float dNewOpen float dNewHigh float dNewLow float dNewClose float dNewVolume float dNewOpenInt Parameters iDate The date of the record you want to change iNewDate The new date value If you do not want to change the value use the value 1 iNewTime The new time value If you do not want to change the value use the value 1 dNewOpen The new open value If you do not want to change the value use the value 1 dNewHigh The new high value If you do not want to change the value use the value 1 dNewLow The new low value If you do not want to change the value use the value 1 dNewClose The new close value If you do not want to change the value use the value 1 dNewVolume The new volume value If you do not want to change the value use the value 1 dNewOpeniInt The new open interest value If you don t want to change the value use the value i Page 33 of 59 Return Values The ChangePriceFields function can raise the following errors File system errors ML_DATE_NOT_FOUND 0x0644 1604 ML_INVALID_DATE 0x0645 1605 ML_NO_DIRECTORY_OPENED 0x0648 1608
12. HRESULT OpenSecurityByFilename BSTR sFileName Parameters sFilename The name of the file containing the security records C MetaStock Dow30 F1 dat Return Values The OpenSecurityByFilename function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section OpenSecurityByName The OpenSecurityByName function opens the price record file Fxxx dat or Fxxx mwd containing the specified security name Before you can use this function you must call the OpenDirectory function HRESULT OpenSecurityByName BSTR sSecurityName Parameters sSecurityName The name of the security Note Security name is not case sensitive Return Values The OpenSecurityByName function can raise the following errors e File system errors ML SECURITY NAME NOT FOUND 0 0643 1603 e ML NO DIRECTORY OPENED 0x0648 1608 For extended error descriptions go to the MetaLib error codes section OpenSecurityBySymbol The OpenSecurityBySymbol function opens the price record file Fxxx dat or Fxxx mwd containing the specified security symbol Before you can use this function you must call the OpenDirectory function HRESULT OpenSecurityBySymbol Page 21 of 59 BSTR sSecuritySymbol Parameters sSecuritySymbol The symbol using to identify the security Note Security symbol is not case sensitive Return Values The OpenSecurityBySymbol function can rais
13. IsMetastockDirectory Checks if a directory contains MetaStock files Returns TRUE if the directory contains MetaStock files Example Dim Reader As New MLReader If Reader IsMetastockDirectory C MetaStock Then Directory contains files Open the directory Reader OpenDirectory MMetaStock Do something Page 19 of 59 iStartIndex Sets the lower bound for the dSeAOpen dSeAClose etc arrays By default this value is o Example If you set the StartIndex property to 0 you have to access the arrays the following way Security File Functions The Security file functions allow you to access security price record files Fxxx dat or Fxxx mwd You should use the functions in the following sequence OpenDirectory OpenSecurity function OpenSecurityByName etc Seek functions optional ReadDay Access Security file properties iseDate dSeOpen etc CloseDirectory and CloseSecurity a B CloseSecurity The CloseSecurity function closes the price record file Fxxx dat or Fxxx mwd that was previously opened with the OpenSecurityBy functions Page 20 of 59 HRESULT CloseSecurity void Parameters This function has no parameters OpenSecurityByFilename The OpenSecurityByFileName function opens the price record file Fxxx dat or Fxxx mwd specified in the sFileName parameter It is not required to call the OpenDirectory function before you call the OpenSecurityByFileName function
14. OpenSecurityBySymbol function doesn t exist in the directory Call the OpenDirectory function to open another directory ML_SECURITY_NAME_NOT_FOUND 0x0643 1603 The name of the security that was passed with the OpenSecurityByName function doesn t exist in the directory Call the OpenDirectory function to open another directory ML_DATE_NOT_FOUND 0x0644 1604 The date that was passed with the SeekToDate function doesn t exist in the specified security file Use the OpenSecurityBy functions to open another security file ML INVALID DATE 0x0645 1605 The date that was passed with the AppendDataRec function is invalid The date must have the following form yyyymmdd ML CREATION OF DIRECTORY FAILED 0x0646 1606 The creation of the directory failed ML DUPLICATE RECORD 0x0647 1607 The security name and the stock name that were passed with the AppendSecurity function already exists in the current directory Call the OpenDirectory function to open another directory ML NO DIRECTORY OPENED 0x0648 1608 You have used the OpenSecurityBy functions without specifying a directory first Before you can call one of the OpenSecurityBy functions you must call the OpenDirectory or CreateDirectory function ML DIRECTORY NOT EXIST 0x0649 1609 The directory that you have tried to open does not exist ML INVALID SECURITY NAME 0x064a 1610 The length of the security name is too short long The security name can have
15. directory the limit for previous versions of the MetaStock data format A maximum of 64000 records be saved for each security e Distributed Form 32 bit Windows DLL Supported Date Range January 1 1910 to December 31 2199 System Requirements Development Environments Visual Basic 5 0 or higher Visual C 4 1 or higher VBA Excel etc Delphi 3 0 or higher JAVA C or any other environment supporting Windows DLLs 32 bit version Windows 95 98 ME 2000 XP 32 MB RAM 64 MB recommended Pentium 75 or higher recommended About 2 megabyte of hard drives space Page 14 of 59 MLReader Interface The MLReader interface provides functions for reading the MetaStock files Master File Properties The properties contain valid data after you have called the ReadMaster or ReadDay function All master file properties are declared as BSTR The Security file properties are declared as floating point numbers Floating point numbers use the IEEE Institute of Electrical and Electronics Engineers format Single precision values with float type have 4 bytes consisting of a sign bit an 8 bit excess 127 binary exponent and a 23 bit mantissa bSymbolExists Returns True if the symbol exists in the currently opened directory sMaEndTime Returns the end time of the current master record The time has the following format hhmmss sMaStartTime Returns the start time of the current master record The time has the
16. do not want to change the value use the value 1 dNewLow The new low value If you do not want to change the value use the value 1 dNewClose The new close value If you do not want to change the value use the value 1 Page 34 of 59 dNewVolume The new volume value If you do not want to change the value use the value 1 dNewOpeniInt The new open interest value If you don t want to change the value use the value 1 Return Values The ChangePriceFields Intraday function can raise the following errors File system errors ML_DATE_NOT_FOUND 0x0644 1604 ML_INVALID_DATE 0x0645 1605 ML_NO_DIRECTORY_OPENED 0x0648 1608 ML_INVALID_TIME 0x064f 1615 For extended error descriptions go to the MetaLib error codes section ChangeSecurityRecord The ChangeSecurityRecord allows you to change the name symbol or the periodicity of a security record of a Master EMaster or XMaster file Before you can use the ChangeSecurityRecord function you must call the OpenDirectory function HRESULT ChangeSecurityRecord BSTR sSecSymbol BSTR sNewSecName BSTR sNewSecSymbol Parameters sSecSymbol The symbol of the security you want to change sNewSecName The new name of the security If you don t want to change the value pass the value 1 sNewSecSymbol The new security symbol If you don t want to change the value pass the value 155 Return Values The ChangeSecurityRecord function can raise the following e
17. following format hhmmss sMaSecName Returns the name of the security EX Coca Cola sMaSecSymbol Returns the ticker symbol for the security EX MSFT sMaSecFileName Returns the filename of the security EX E Trading Vienna f1 dat iMaFirstDate Returns the first date that is stored in a Fxxx xxx file EX 19991214 The date is stored in the following format yyyymmad iMaLastDate Returns the last date that is stored in a Fxxx xxx file EX 19991214 The date is stored in the following format yyyymmad iMaNrFields Returns the field size of the security The value can be between 4 Tick and 8 Malnterval Returns the interval of the security The MaInterval can have the following values None Page 15 of 59 Tick 1 Minute 5 Minute 6 Minute 10 Minute 15 Minute 20 Minute 30 Minute 60 Minute MaPeriodicity Returns the periodicity of the security The MaPeriodicity can have the following values Intraday Daily Weekly Monthly Master File Functions The master file functions allow you to access a master file of directory specified in the OpenDirectory function You should use the functions in the following sequence 1 OpenDirectory 2 ReadMaster 3 Access Master file properties 5 sMaSecSymbol etc 4 CloseDirectory CloseDirectory The CloseDirectory function closes the directory that was previously opened with the OpenDirectory function Call this function before you w
18. function can raise the following exceptions e File system errors For extended error descriptions go to the MetaLib error codes section Example Dim Converter As new MLConverter Converter MetaStock2CSV C MMetastock C NCSV True False MLProgBar Interface MLProgBar Properties bCancel Check this property periodically to determine if the user has cancelled the operation Return Value TRUE if the user has selected the Cancel button otherwise false bEnableCancelButton Set this option to TRUE if you want that a cancel button is displays on the progress bar Otherwise set this option to FALSE The default value of this property is TRUE Page 46 of 59 MLProgBar Functions The MLProgBar functions allow you to use a progress dialog in your application A progress dialog is what you commonly see during setup operations It contains a progress indicator for updating the user on the completion status of a lengthy operation The progress dialog includes the following features e Cancel button along with a message handler for the button optional status text window percentage display of the current status Create Call this function to create the progress dialog HRESULT Create void Parameters This function has no parameters Return Value The Create function can raise the following errors ML PROGRESSBAR FAILED 0x0663 1635 For extended error descriptions go to the MetaLib error codes section De
19. sSeldir C MetaStock MsgBox Selected security sSeldir r OpenSecurityByFilename sSeldir MsgBox Number of data records r iSeRecords OpenDirectory The OpenDirectory function opens the Master file of the specified MetaStock directory HRESULT OpenDirectory BSTR sDirectory Parameters sDirectory Page 17 of 59 The name of the directory containing the MetaStock files Return Values The OpenDirectory function can raise the following errors e File system errors e ML_DIRECTORY_NOT_EXIST 0x0649 1609 For extended error descriptions go to the MetaLib error codes section ReadMaster The ReadMaster function reads a security record from the current file position You can access the security record if you use the master file properties Before you can use the ReadMaster function you must call the OpenDirectory function HRESULT ReadMaster void Parameters The function has no parameters Return Values The ReadMaster function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Example This example reads all records of a master file and displays the security names Dim Reader As New MLReader Reader OpenDirectory C MetaStock Do While Reader iMaRecordsLeft gt 0 Reader ReadMaster MsgBox Reader sMaSecName Loop Reader CloseDirectory Security File Properties iSeADate Returns the date array of a security price rec
20. 00 32 1300 2 D500 IS LO IL Using the split function Dim w As New MLWriter w OpenDirectory C Metastock w OpenSecurityBySymbol MSFT w Split 2 1 true Price records after using the Split function Open High Low Close Volume 16 5900 16 6400 16 0650 16 4750 2703602 UpdateChart The UpdateChart function updates the values of opened charts in MetaStock in real time The chart will be updated automatically and you do not have to press the refresh button in MetaStock manually anymore Note This function is only available in the Real time version of MetaLib Dim Writer As New MLWriter Writer OpenDirectory C MetaStock Writer OpenSecurityBySymbol MSFT Writer AppendDataRec 20001021 0 23 12 24 11 21 02 24 2 0 0 Writer UpdateChart MLSecurityFinder Interface The MLSecurityFinder interface provides functions to search for securities in directories A search progress dialog can be displayed during this operation Page 42 of 59 MLSecurityFinder Functions DestroySearchDialog If the bDisplaySearchDialog parameter is set to TRUE MetaLib displays a progress dialog during the search After the search has finished you must call the DestroySearchDialog function that the dialog will disappear HRESULT DestroySearchDialog void Return Values The DestroySearchDialog function can raise the following errors e ML SEARCH DIALOG FAILED 0x0664 1636 For extended error descriptions go to t
21. 19991214 to the end of a security file and displays the price records in a message box Dim Reader As New MLReader Reader OpenDirectory C MetaStock Reader OpenSecurityBySymbol MSFT Reader SeekToDate 19991214 Do While Reader iSeRecordsLeft gt 0 Reader ReadDay read price record MsgBox Reader iSeDate Chr 9 amp Reader iSeHigh amp Chr 9 amp Reader iSeLow amp Chr 9 amp Reader iSeClose Loop Reader CloseDirectory SeekToEnd The SeekToEnd function sets the position of the file pointer to the logical end of the file To open a security file use the OpenSecurityBy functions No data is actually read during the seek HRESULT SeekToEnd void Parameters This function has no parameters Return Values The SeekToEnd function can raise the following errors e File system errors e ML BAD SEEK 0x067b 1659 For extended error descriptions go to the MetaLib error codes section Example This example reads the last record of a price record file Fxxx dat or Fxxx mwd file and displays the price record in a message box Dim Reader As New MLReader Reader OpenDirectory C MetaStock Reader OpenSecurityBySymbol MSFT Reader SeekToEnd Move pointer to the file end Reader Seek 1 and move up one record Do While Reader iSeRecordsLeft gt 0 Reader ReadDay MsgBox Reader iSeDate amp Chr 9 amp Reader dSeHigh amp Chr 9 amp Reader dSeLow amp Chr 9 amp Reader dSeClose Loop Rea
22. 2 0 0656 52 ML PRICE RECORD ALREADY EXISTS 0 0657 1623 52 ML FAILED TO DIAL UP 0x065e 1630 52 ML SERVER CONNECTED 0 065 1631 53 ML FAILED TO HANG UP 0x0660 1632 53 ML CONNECTION NAME NOT FOUND 0x0661 1633 53 ML PROGRESSBAR FAILED 0x0663 1635 53 ML SEARCH DIALOG FAILED 0x0664 1636 53 File system error ence eee ee eene nene hene n emi hene sse esee nnne nns 53 ML DISK FULL 0x06727 1650 cites ERE 53 ML TOO MANY OPEN FILES 0x0673 1651 53 55 DENIED 0x0674 1652 aa 53 ML LOCK VIOLATION 0x0675 1653 53 ML SHARING VIOLATION 0x0676 1654 53 ML HARD 10 0 0677 1655 Ie ria 53 ML INVALID FILE 0x0678 1656 53 Page 4 of 59 ML FILE NOT FOUND 0 0679 1657 memes 53
23. ALREADY EXISTS 0x0657 1623 For extended error descriptions go to the MetaLib error codes section Example The following example calculates random values and saves these values to MetaStock files Dim Writer As New MLWriter Dim iDate As Long Writer CreateDirectory C MetaStock Randomize Timer poe s 1 ume 270 Writer AppendSecurity SecSymbol CStr i SecName CStr i Daily iDate 20000104 oe j 4 To 20 fOpen Int Rnd 500 Ria 5001 TROW ALiatie Weave 600 fClose Int Rnd 500 fVolume Int Rnd 10000 owe 10000 Writer AppendDataRec iDate 0 fOpen fHigh fLow fClose fVolume iOpenInt Page 30 of 59 iDate iDate 1 Next j Next i AppendDataRecArray The AppendDataRecArray function adds a price record array to a security price record file Fxxx dat or Fxxx mwd All arrays must have the same size Before you can use the AppendDataRecArray function you must call one of the OpenSecurityBy functions or the AppendSecurity function HRESULT AppendDataRecArray SAFEARRAY int iDate SAFEARRAY int iTime SAFEARRAY float dOpen SAFEARRAY float dHigh SAFEARRAY float dLow SAFEARRAY float dClose SAFEARRAY float dVolume SAFEARRAY float dOpenInterest Parameters iDate The date must have the following format YYYYMMDD iTime The time must have the following format HHMMSS dOpen Open quotation dHigh High quotatio
24. DAMAGES WHATSOEVER INCLUDING DIRECT INDIRECT INCIDENTAL CONSEQUENTIAL LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES WHICH MAY RESULT FROM THE USE OF METALIB EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES MetaStock is a registered trademark of EQUIS International http Awww equis com CompuTrac is a registered trademark of Dow Jones Telerate Page 58 of 59 Contact We provide support via email You can email your questions comments or bug reports to info trading tools com Normally all emails are answered throughout the 24 hour day Web http www trading tools com Special thanks to Elden Taylor for providing a Delphi example project and Thomas Pfluegl for the MetaLib idea for testing and for developing the MetaLib Tools Excel workbook MetaLib Tools xls This spreadsheet implements some basic features of MetaLib and is available at http members aon at tips download htm Web http members aon at tips index html Page 59 of 59
25. INVALID_SECURITY_NAME 0x064a 1610 ML_INVALID_SYMBOL 0x064b 1611 ML_TOO_MUCH_SEC_FILES 0x064c 1612 For extended error descriptions go to the MetaLib error codes section Example The following example only adds a security to a directory Dim Writer As New MLWriter Writer CreateDirectory C MetaStock Writer AppendSecurity MSFT Microsoft Daily helices 2001021 0 125 200 100 123 322i 0 Writer CloseDirectory AppendDataRec The AppendDataRec function adds a price record to a security price record file Fxxx dat or Fxxx mwd Before you can use the AppendDataRec function you must call one of the OpenSecurityBy functions or the AppendSecurity function Call the Sort function if you want to sort the price records after you have used the AppendDataRec function Page 29 of 59 HRESULT AppendDataRec int iDate int iTime float dOpen float dHigh float dLow float dClose float dVolume float dOpenInterest Parameters iDate The date must have the following format YYYYMMDD iTime The time must have the following format HHMMSS dOpen Open quotation dHigh High quotation dLow Low quotation dClose Close quotation dVolume Volume dOpeniInterest Open interest Return Values The AppendDataRec function can raise the following errors File system errors ML INVALID DATE 0x0645 1605 ML NO DIRECTORY OPENED 0x0648 1608 ML INVALID TIME 0x064f 1615 ML PRICE RECORD
26. METALIB V5 0 Copyright C 2008 Trading Tools com mailto info trading tools com User manual Table of Contents Table of Contents 2 Getting Started WG IC OMG i ise Sead oi oases IEEE 5 How to add MetaLib to your Visual Project cece eee eects tees meme 6 How to add MetaLib to your JAVA 8 How to add MetaLib to your Visual Basic 8 How to add MetaLib to your VB NET 9 How to add MetaLib to your C C VS NET 2003 VS NET 2005 Project 10 How to add MetaLib to your Delphi Project 11 Technical Specifications xs Ere Ox aaea aa nirean 14 System Requirements 2 sees etui ir leo rA IR ipe Dici Di Re eds 14 Reader Interface D Master File Properties E ERR RESERVE EE SENE ote 15 bSymbolEXiStS 15 sMaEndTimo6 zeiten prie qur cen ance Desa dA 15 SMaStart Mme Wa eins i 15 15 sMaSecSymbol 4 5 AE AEA A DRE
27. ML_BAD_PATH 0x067a 1658 ON Y 53 BAD SEEK 0x067b 1659 dones dept bu ri A RENE E DIRE 54 ML GENERIC L660 54 Metastock Format Description 95 File Structure Description 55 Registration and Price Information 96 How to use the Registration Key 56 Deploying MetaLib rrr nrnar antur s runter Disclaimer of Warranly o ranor nra nnn ru inu sun nne n innuit air o M Getting Started Welcome The MetaLib SDK provides functions for reading writing sorting MetaStock security and price data The MetaLib library removes many of the complexities of accessing MetaStock data files from your program As a result your development time will be shorter 1 DestoySearchDiaing FndNextSecuntyt gt FndSecumyBS TR eSecutyName BSTR sDrectony 29 SecFieName BS TR pal P SecName BSTR SecSymbolBSTR pali eP sSearchDialogT HefSSTA newValJ sSearchDialogT tefBSTA pal IML Whiter Append saRecfBSTR 0 int double dO pen double diigh double dLow double AppendO BSTR sDate SAFEA
28. ML_INVALID_TIME 0x064f 1615 For extended error descriptions go to the MetaLib error codes section Example This example changes a security record of the C Vienna fl dat file Dim Writer As New MLWriter Writer OpenSecurityByFilename C MetaStock fl dat The date of the record won t be changed Some price values will be changed Writer ChangePriceFields 20001021 1 1 23 1 24 11 21 02 24 2 32321 202 The date of the record will be changed Some price values will be chaged Writer ChangePriceFields 20001022 200001023 1 1 1 1 20 32321 0 Writer CloseDirectory ChangePriceFieldsIntraday The ChangePriceFieldsIntraday function allows you to change an intraday price record of a security price record file Fxxx dat or Fxxx mwd Before you can use the ChangePriceFieldsIntraday function you must call one of the OpenSecurityBy functions HRESULT ChangePriceFields int iDate int iNewDate int iTime int iNewTime float dNewOpen float dNewHigh float dNewLow float dNewClose float dNewVolume float dNewOpenInt m Parameters iDate The date of the record you want to change iNewDate The new date value If you do not want to change the value use the value 1 iTime The time of the record you want to change iNewTime The new time value If you do not want to change the value use the value 1 dNewOpen The new open value If you do not want to change the value use the value 1 dNewHigh The new high value If you
29. OT FOUND 0x0643 1603 e ML NO DIRECTORY OPENED 0x0648 1608 For extended error descriptions go to the MetaLib error codes section Example This example adds a security record at the end of a fxxx xxx the file that was opened with the OpenSecurityByName function Dim Writer As New MLWriter Writer OpenDirectory C MetaStock Writer OpenSecurityByName Microsoft Writer AppendDataRec 20001021 0 23 12 24 11 21 02 24 2 0 0 Writer CloseDirectory OpenSecurityBySymbol The OpenSecurityBySymbol function opens the Fx xxx file that contains the specified security symbol Use the AppendDataRec function to add price records to the specified file Before you can call this function you must call the OpenDirectory function HRESULT OpenSecurityBySymbol BSTR sSecuritySymbol m Parameters sSecuritySymbol The ticker symbol for the security Note Security symbol is not case sensitive Return Values The OpenSecurityBySymbol function can raise the following errors e File system errors e ML SECURITY SYMBOL NOT FOUND 0x0642 1602 e ML NO DIRECTORY OPENED 0x0648 1608 For extended error descriptions go to the MetaLib error codes section Example This example adds a security record at the end of a security price record file opened by the OpenSecurity BySymbol function Dim Writer As New MLWriter Writer OpenDirectory C WMMetaStock Writer OpenSecurityBySymbol MSFT Writer AppendDataRec 20001021 0 23 12 24 11 21 02 24 2 0
30. OT FOUND 0x0644 1604 51 ML INVALID DATE 0x0645 1605 nnn nnne nnn 51 ML CREATION OF DIRECTORY FAILED 0x0646 1606 51 ML DUPLICATE RECORD 0x0647 1607 cee ee eee eens eee Hem 51 ML NO DIRECTORY OPENED 0 0648 1608 51 ML DIRECTORY NOT EXIST 0x0649 1609 51 ML INVALID SECURITY NAME 0x064a 1610 51 ML INVALID SYMBOL 0x064b 1611 51 ML TOO MUCH SEC FILES 0x064c 1612 51 ML FILE IS USED BY ANOTHER APP 0x064d 1613 51 ML INVALID TIME FRAME 0x064e 1614 52 ML ONLY FOR US MARKET 0x0650 1616 52 ML CONTAINS NO METASTOCK FILES 0x0651 1617 52 ML FAILED TO DEL PRICE RECORD 0 0652 1618 52 ML FAILED TO CHANGE PRICE RECORD 0x0653 1619 52 ML ARRAYS MUST HAVE SAME SIZE 0x0654 1620 52 ML COPYRIGHT STRING TOO LONG 1621 0 0655 52 ML NO QUOTES AVAILABLE 162
31. OpenSecurityBy functions HRESULT ReadDayArray void Parameters Page 22 of 59 This function has no parameters Return Values The ReadDayArray function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Example This example reads all records of a price record file and saves them to an array and displays all values in a message box Seek The Seek function repositions the pointer in a previously opened file To open a security file use the OpenSecurityBy functions No data is actually read during the seek After you have called the Seek function you should call the ReadDay function to read records from the specified position HRESULT Seek int iNrOfDays Parameters iNrOfDays Number of days to move the pointer This value can be gt 0 lt 0 Return Values The Seek function can raise the following errors e File system errors Page 23 of 59 ML BAD SEEK 0x067b 1659 For extended error descriptions go to the MetaLib error codes section Example This example reads the last record of a price record file Fxxx dat or Fxxx mwd file and displays the price record in a message box Dim Reader As New MLReader Reader OpenDirectory C MetaStock Reader OpenSecurityBySymbol MSFT Reader SeekToEnd Move pointer to the file end Reader Seek 1 and move up one record Do While Reader iSeRecordsLeft gt 0 Reader
32. Project 1 Click on the Project gt Import Type Library menu 2 The Import Type Library dialog will appear Page 11 of 59 3 Select the MetaLib 5 0 entry 4 Make sure that the Generate Component Wrapper check box is unchecked 5 Click on the Create Unit button Listed below is the main Uniti which shows proper connection has been established with 5 2 D gt 3r So aa lt awn 5 5 lt BX 5 jua Ow 50 go zd wn o cr 5 38 cae lt 53 o 5 p 5 12 of 59 Page 13 of 59 just another routine you want end initialization CONTEN e Reg CreateComObject Class MLRegistration IMLRegistration Reg SetRegistrationInfo Your Name Your key number Reader CreateComObject Class MLReader as IMLReader Reg DisplayAboutDlg finalization CoUninitialize Reg nil Reader nil end Note Set Listbox Events OnClick and OnEnter to MReader Technical Specifications e MetaLib supports the latest Y2K compatible MetaStock version 8 0 data format e Data for up to 6000 securities can be stored in each directory However the fewer securities you have in a folder the better the performance of programs that access the data e g MetaStock will be Some programs still won t recognize more than 255 securities in a
33. RD 0x0677 1655 There was a hardware error ML INVALID FILE 0x0678 1656 There was an attempt to use an invalid file handle ML FILE NOT FOUND 0x0679 1657 The file could not be located ML BAD PATH 0x067a 1658 All or part of the path is invalid Page 53 of 59 ML_BAD_SEEK 0x067b 1659 There was an error trying to set the file pointer ML_GENERIC 0x067c 1660 An unspecified error occurred Page 54 of 59 Metastock Format Description File Structure Description Metastock uses three files to store its information Master This is the main file that is created and put in a directory and it contains the information of all the files that are stored in the directory Every stock is saved stored in an Fx dat or Fx mwd file The x here represents a number Master The Master file contains the following information Total Record Number Highest Record Used Copyright Info Chat values usage File Number Number of Fields Auto Flag Record Size Symbol File Name Time Frame I D W M Time Interval the time between trades in minute intervals minimum 1 minute First Date on Record The beginning of the trade for the stock of the present date Last Date on Record The end of the trade for the stock of the present date Start of trading End of trading Fx dat and Fx mwd file The Fx dat and Fx mwd files contain the following information Date Time Open High Low C
34. RRAY nt SAFEARRAY AppendintradaySecunt BS TR sSecurtySymbol BSTR tSecurtyN ame INTERVAL enminterval nt 3 AppendSecurtBS sSecuntySymbol BSTR sSecuntyN ame PERIODICITY enmPenodctyl 29 bSymbolExstslBSTR sSymbol VARIANT BOOL pva VARIANT BOOL pwiteFirstLastDate VARIANT BODL pal LhangePnceFields BS TR 10 ate BSTR sNewDate int INewT ime double dNew pen double AiewH gt LhangeSecurtyRecordlB5 sSecSymbol 85 sNewSecName BSTR sNewSecS ymboll gt D CiesteDiecton BS TR sDeectory gt STR sDate gt 5 sDateFrom BSTR 10 2 DeleteSecumyB S TR sSecSymbol OpenDiecton BS TR sDerectery penSecumyByFdename BS TR Filename OpenSecunyB yName BSTR sSecuntyN ame OpenSecunmyBySymbol BS TR sSecuntyS ymbol 3 E This picture displays some methods of MetaLib Page 5 of 59 MetaStock is a registered trademark of Equis International in the United States and other countries How to add MetaLib to your Visual C Project 1 Open your VC project 2 Add the MLErrorConstants h and MLUtil h file to your project 3 Add the following lines to the Stdafx h file 4 Add the following lines to your Stdafx cpp file Page 6 of 59 5 To initialize the Metalib interfaces add the following code e g to your InitInstance function This funct
35. a stock split Please use caution when applying this command Once an adjustment is made it may be difficult to bring the data back to its original state Use the Sp itEx function if you want to set a start and end date of the price records that should be splitted HRESULT Split float fRatio float fRatio2 optional VARIANT_BOOL bSplitVolume Parameters Page 41 of 59 fRatio fRatio2 e g 2 for 1 3 for 2 etc bSplitVolume Set this value to TRUE if you also want to split the volume default Return Values The Split function can raise the following errors e File system errors e ML_DATE_NOT_FOUND 0x0644 1604 e ML FAILED TO SPLIT PRICE RECORD 0x0659 1626 More info When a stock splits the historical prices must be adjusted to reflect the split For example if XYZ company has a 2 for 1 stock split shareholders will receive two shares for each share that they own To keep the total market value of the stock equal the price per share is reduced by one half Therefore shareholders will have twice as many shares at half the price Stock splits are usually done in order to increase the liquidity of the stock When price data is adjusted for a stock split the volume is also affected For example in a 2 for 1 split where prices are cut in half the volume is doubled so that the market value remains unchanged Example Price records before using Split function Open High Low Close Volume 33 1800 33 28
36. adaySecurity function can raise the following errors File system errors ML_DUPLICATE_RECORD 0x0647 1607 ML_NO_DIRECTORY_OPENED 0x0648 1608 ML_INVALID_SECURITY_NAME 0x064a 1610 ML_INVALID_SYMBOL 0x064b 1611 ML_TOO_MUCH_SEC_FILES 0x064c 1612 ML_INVALID_TIME 0x064f 1615 For extended error descriptions go to the MetaLib error codes section Page 28 of 59 Example The following example adds an intraday security to the directory Dim Writer As New MLWriter Writer CreateDirectory C MetaStock Writer AppendIntradaySecurity MSFT Microsoft Minutel 90000 153000 Writer AppendDataRec 20000101 141500 10 20 9 19 2323 8333 Writer CloseDirectory AppendSecurity The AppendSecurity function adds a security record to a directory Before you can use the AppendSecurity function you must call the CreateDirectory or OpenDirectory function If you want to add price records to this security record use the AppendDataRec function HRESULT AppendSecurity BSTR sSecuritySymbol BSTR sSecurityName PERIODICITY sPeriodicity Parameters sSecuritySymbol The ticker symbol for the security max 14 chars sSecurityName The name of the security max 45 chars sPeriodicity sPeriodicity can have following values Intraday Daily Weekly Monthly Return Values The AppendSecurity function can raise the following errors File system errors ML_DUPLICATE_RECORD 0x0647 1607 ML_NO_DIRECTORY_OPENED 0x0648 1608 ML_
37. ant to open another master file HRESULT CloseDirectory void Parameters This function has no parameters DisplayMSDirBrowser The DisplayMSDirBrowser function displays a dialog that allows you to browse for MetaStock directories Page 16 of 59 C WetaStockWSA S amp P 500 MetaStock Austria KNIGHT RIDDER INC ATX Midcap LEGGETT PLATT INC Genev LEHMAN BROS HLD LENNAR CP CLA BSE 100 LABORATORY CORP N E MSSmar LIZ CLAIBORNE INC Q Se L 3 COMM HLDGS IN Singapore LINEAR TECHNOLOGY BT SRI m LEGG MASON INC E Strate Time LOCKHEED MARTIN USA LILLY ELI CO Dow Jones 15 Utili LNC LINCOLN NATL CP Dow Jones 30 Ind LOWES COMPANIES NYSE Composite T LOUISIANA PACIFIC 2 S amp P 100 2 LSILOGIC CP S amp P 500 LIMITED BRANDS IN LOEWS CP HRESULT DisplayMSDirBrowser out BSTR sSelectedSymbolFileName optional BSTR sDirectoryToDisplay optional BSTR sReserved Parameters sSelectedSymbolFileName Returns the file name of the selected security e g C MetaStock F1 You can pass this value to the OpenSecurityByFilename function If no security was selected the sSelectedSymbolFileName variable is empty sDirectoryToDisplay You can define a directory that will be displayed when the dialog opens sReserved Reserved for future use Should be NULL Example Dim r As New MLReader Dim sSeldir As String r DisplayMSDirBrowser
38. der CloseDirectory Page 25 of 59 SeekToNearestDate The SeekToNearestDate function repositions the pointer in a previously opened file to the specified date To open a security file use the OpenSecurityBy functions If the date does not exist the previous Set the bUp parameter to FALSE or the next Set the bUp parameter to TRUE date in the file will be used No data is actually read during the seek After you have called the Seek function you must use the ReadDay function to read records from the specified position HRESULT SeekToNearestDate BSTR sDate BOOL bUp Parameters sDate The date where to move the pointer The date must have the following format yyyymmdd bUp Direction where to move the file pointer if the date does not exist Return Values The SeekToNearestDate function can raise the following errors File system errors ML BAD SEEK 0x067b 1659 For extended error descriptions go to the MetaLib error codes section Other Properties sDirectory Returns the name of the currently opened MetaStock directory Read only MLWriter Interface The MLWriter interface provides functions to write to MetaStock files You can add rename delete securities add rename delete price records sort price records and much more There are three possibilities to add a price record to a security file 1 Call the OpenDirectory function of the MLWriter interface Use the OpenSecurityBySymbol or OpenSecuri
39. e end time of the time range Return Values The DeleteIntradaySecRecordEx function can raise the following errors e File system errors e ML DATE NOT FOUND 0x0644 1604 e ML FAILED TO DEL PRICE RECORD 0x0652 1618 For extended error descriptions go to the MetaLib error codes section DeleteSecurity The DeleteSecurity function allows you to remove a security record from a Master EMaster or XMaster file Before you can use the DeleteSecurity function you must call the OpenDirectory function HRESULT DeleteSecurity BSTR sSecSymbol Parameters sSecSymbol The symbol of the security you want to delete Return Values The DeleteSecurity function can raise the following errors e File system errors ML SECURITY SYMBOL NOT FOUND 0 0642 1602 ML INVALID SYMBOL 0x064b 1611 For extended error descriptions go to the MetaLib error codes section Page 37 of 59 Example This example removes the security MSFT from the directory Dim Writer As New MLWriter Writer OpenDirectory C MetaStock Writer DeleteSecurity MSFT Writer CloseDirectory DeleteSecurities The DeleteSecurities function allows you to remove one or more security records from a Master EMaster or XMaster file Before you can use the DeleteSecurities function you must call the OpenDirectory function Note This function cannot be called from Visual Basic HRESULT DeleteSecurities SAFEARRAY BSTR sSecuritySymbols m Parameters
40. e the following errors File system errors e ML SECURITY SYMBOL NOT FOUND 0x0642 1602 e ML NO DIRECTORY OPENED 0x0648 1608 For extended error descriptions go to the MetaLib error codes section ReadDay The ReadDay function reads a price record date open high etc from the current file position You can access the price record if you use the security file properties Before you can use the ReadDay function you must call one of the OpenSecurityBy functions HRESULT ReadDay void Parameters This function has no parameters Return Values The ReadDay function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section Example This example reads all records of a price record file Fxxx dat or Fxxx mwd and displays them Dim Reader As New MLReader Reader OpenDirectory C MetaStock Reader OpenSecurityBySymbol MSFT Do While Reader iSeRecordsLeft gt 0 Reader ReadDay MsgBox Reader iSeDate amp Chr 9 amp Reader dSeHigh amp Chr 9 _ amp Reader dSeLow amp Chr 9 amp Reader dSeClose Loop Reader CloseSecurity Reader CloseDirectory ReadDayArray The ReadDayArray function reads a price record array date open high etc from a price record file Fxxx dat or Fxxx mwd All price records of the files will be stored in arrays dSeAOpen dSeAHigh dSeAClose etc Before you can use the ReadDay function you must call one of the
41. eateDirectory function can raise the following errors e File system errors e ML CREATION OF DIRECTORY FAILED 0x0646 1606 For extended error descriptions go to the MetaLib error codes section DeletelntradaySecRecord The DeleteIntradaySecRecord function removes an intraday price record of a security price record file Fxxx dat or Fxxx mwd Before you can use the DeleteIntradaySecRecord function you must call one of the OpenSecurityBy functions HRESULT DeleteIntradaySecRecord int iDate int iTime m Parameters iDate The date of the intraday price record you want to delete iTime The time of the intraday price record you want to delete Return Values The DeleteIntradaySecRecord function can raise the following errors File system errors Page 36 of 59 ML DATE NOT FOUND 0x0644 1604 e ML FAILED TO DEL PRICE RECORD 0x0652 1618 For extended error descriptions go to the MetaLib error codes section DeletelntradaySecRecordEx The DeleteIntradaySecRecordEx function removes one ore more intraday price records of a security price record file Fxxx dat or Fxxx mwd between a certain time range Before you can use the DeleteIntradaySecRecordEx function you must call one of the OpenSecurityBy functions HRESULT DeleteIntradaySecRecordEx int iDate int iTimeFrom int iTimeTo Parameters iDate The date of the intraday price record you want to delete iTimeFrom The start time of the time range iTimeTo Th
42. ep increment for a progress bar The step increment is the amount by which a call to StepIt increases the progress bar s current position HRESULT SetStep int iStep Parameters iStep New step increment Steplt Advances the current position for a progress bar control by the step increment and redraws the bar to reflect the new position The step increment is set by the SetStep member function HRESULT StepIt void Parameters Page 48 of 59 This function has no parameters Page 49 of 59 MetaLib Error Codes To catch the MetaLib errors use the following mechanism VB VBA Use the On Error Goto statement C Use the SUCCEEDED and FAILED macros to determine if the function succeeded failed To display HRESULT values its recommended that you display the error codes in Hexadecimal Display For example the ML_SECURITY_NAME_NOT_FOUND error has the following error value 0x800a0643 Take the last three digits and compare this number with the error constants in the MLErrorConstatns h file Now you know the name of the error that was raised by one of the MetaLib functions MetaLib can raise the following errors General Error Codes ML_FILE_NAME_NOT_FOUND 0x0641 1601 The file name that was passed with the OpenSecurityByFilename function doesn t exist Page 50 of 59 ML_SECURITY_SYMBOL_NOT_FOUND 0x0642 1602 The symbol name of the security that was passed with the
43. erences Projekt1 vbp Visual Basic For Applications Visual Basic runtime objects and procedures Visual Basic objects and procedures wv OLE Automation 145 Helper COM Component 1 0 Type Library Microsoft Internet Controls 4 2 IAS RADIUS Protocol 1 0 Type Library 802 1XConfig 1 0 Type Library 1 0 Type Library AccAOL 1 0 Type Library Access2000Desgner Express 1 0 Type Library Access97Designer Express 1 0 Type Library ACF AnnCH 1 9 Tyne Metab 4 9 Location 3 Select the MetaLib 5 0 entry 4 Close the dialog 5 Optional Add the MetaLibUtil Bas C MetaLib Include file to your project How to add MetaLib to your VB NET project 1 Click on Project gt Add Reference 2 The Add Reference dialog will appear Page 9 of 59 Add Reference AReleaseMinDepen C lProgrammelMicrosoft C ProgrammelMicrosoft Microsoft Access 10 0 Object Microsoft ACT Application Obj Microsoft Test Object Mo Microsoft Active Server Pages Microsoft ActiveMovie Control C Programme Micrasoft ACT C AProgrammelMicrosoft visu C AWINDOWSIsystem32lamc Microsoft ActiveX Data Object Microsoft Activex Data Object Microsoft Activex Data Object C Programme Gemeinsame C Programme Gemeinsame C ProgrammelGemeinsame C Programme Gemeinsame C Programme Gemeinsame CAPronranme Gameinsame Microsoft ActiveX
44. he MetaLib error codes section FindNextSecurity The FindNextSecurity function continues a security search from a previous call to the FindSecurity function HRESULT FindNextSecurity void Return Values The FindNextSecurity function can raise the following errors File system errors e ML_SECURITY_NAME_NOT_FOUND 0 0643 1603 For extended error descriptions go to the MetaLib error codes section FindSecurity The FindSecurity function allows you to search for a specified security name symbol in MetaStock files that are stored in a directory Use the FindNextSecurity function to continue the security search HRESULT FindSecurity BSTR sSecurityName BSTR sDirectory Parameters sSecurityName The name of the security name or security symbol Note Security name symbol is not case sensitive The parameter can contain wildchars like or sDirectory The name of the directory where to start the search If the fScanSubDirectories property is set to TRUE MetaLib scans through all subdirectories of the directory specified in the sDirectory parameter Return Values The FindSecurity function can raise the following errors e File system errors e ML SECURITY NAME NOT FOUND 0 0643 1603 Page 43 of 59 For extended error descriptions go to the MetaLib error codes section Example This example scans trough all directories of C and checks if there are some MetaStock files contai
45. he SetRegistrationInfo you must specify the registration name and the registration key After you have done this MetaLib is unlocked and provides full functionality It is recommended that you call the SetRegistrationInfo when you start your program In Visual Basic add the following code lines in the Form_Load procedure of your main form Private Sub Form Load Registration SetRegistrationInfo YOUR NAME YOUR KEY End Sub Add a module to your VB project and add following line Public Registration As New MLRegistration If you are using NET add following line Public Registration As New METALIBLib MLRegistration In Visual C add the following code lines to the InitInstance function BOOL CMLYourApp InitInstance g IMLRegistration SetRegistrationInfo L YOUR NAME L YOUR KEY RUE Deploying MetaLib You only have to include the MetaLib DLL file to your application Make sure that the DLL will be registered on the target computer regsvr32 C MetaLibPath Metalib dll No other files are needed Disclaimer of Warranty Users of MetaLib must accept this disclaimer of warranty If you do not accept this disclaimer do not use MetaLib METALIB IS SUPPLIED AS IS THE AUTHOR DISCLAIMS ALL WARRANTIES OF ANY KIND EITHER EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES Page 57 of 59 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
46. ion is located in the class CYourApplicationNameApp if FAILED CoCreateInstance CLSID_MLRegistration NULL CLSCTX_INPROC_SERV void amp g_IMLRegistration I IMLRegistration SetRegistrationInfo interface pointers add the following code e g to the d CyourApplicationNameApp class Release all interface pointers if g IMLWriter NULL IMLWriter Release g IMLWriter NULL 0 if g_IMLReader NULL IMLReader Release g IMLReader NULL 0 if g_IMLProgBar NULL IMLProgBar Release g IMLProgBar NULL 0 if g_IMLConverter NULL g_IMLConverter gt Release g_IMLConverter NULL if g_IMLRegistration 1 NULL g IMLRegistration Release g IMLRegistration NULL How to add MetaLib to your JAVA Project L YOUR NAM ER IID IMLRegistration RACE Failed to create the IID IMLRegistration object n E L YOUR KEY It is necessary to release all interface pointers you have used To release all estructor of the You need a COM bridge like the JACOB project http danadler com jacob if you want to use MetaLib with JAVA Download the COM bridge from thi instructions is site and follow the How to add MetaLib to your Visual Basic Project Steps to add MetaLib to your VB VBA project 1 Start the Visual Basic Editor ALT F11 Page 8 of 59 2 Open the References dialog Ref
47. iue RW 45 2 46 Interface 46 MEProgBar Properti8s 2 2 enne tenete 46 eripe mL 46 bEnableCancelB tton i cai aD xD IEDV A AR D ca Rd ARI 46 MEProgBar F rnctlofis seo eei ERR p RR DE Roa AUR R 47 GOAL 47 47 47 Pee dab ka e Daven E Gk aval dele throne avoids 47 SETRANG Grinch aad RD E 48 si TTM E 48 48 h O O 48 MetaLib Error Codes 00 50 ccc EE 50 General Error CodeS ir Rr ira cir 50 ML FILE NAME NOT FOUND 0 0641 1601 50 ML SECURITY SYMBOL NOT FOUND 0x0642 1602 51 ML SECURITY NAME NOT FOUND 0x0643 1603 51 ML DATE N
48. lose Volume Page 55 of 59 Registration and Price Information If you decide to use the MetaLib SDK only for private purposes you have to order the private licence for 59 95 EURO If you decide to use the MetaLib SDK for commercial products you have to order the commercial version of MetaLib 249 95 EURO If you want to update opened charts in MetaStock real time you have to order the real time version of MetaLib 449 95 EURO Licence type Price Use Private 59 95 EUR Only for private purposes You can only install MetaLib on these computers that are owned by you Commercial 249 95 EUR For private and commercial purposes You can distribute MetaLib to as many PCs as you want Real time 449 95 EUR For private and commercial purposes You can distribute MetaLib to as many PCs as you want Charts that are opened in MetaStock can be refreshed automatically with the MetaLib DLL in real time UpdateChart function is only available in this version This copy of MetaLib is available for a 20 days evaluation period If you decide to continue using the program you need to register the program by using one of the methods described below By registering the software you are able to continue using it legally and are supporting our efforts to continually develop innovative products to best serve your needs If you order via credit card you receive the fully registered version of MetaLib within 5 minutes
49. max 45 chars ML INVALID SYMBOL 0x064b 1611 The length of the security symbol is too short long The security symbol can have max 14 chars ML TOO MUCH SEC FILES 0x064c 1612 The maximum number of security files in one directory has been reached Only 2000 security files can be stored in one directory ML FILE IS USED BY ANOTHER APP 0 064 1613 The file is used by another application You must close the running application first Page 51 of 59 ML_INVALID_TIME_FRAME 0x064e 1614 Supported time frames D daily W weekly M monthly ML ONLY FOR US MARKET 0 0650 1616 Historical quotes are only available for the US market ML CONTAINS NO METASTOCK FILES 0x0651 1617 The directory contains no MetaStock files You must select a another direcotory ML FAILED TO DEL PRICE RECORD 0x0652 1618 Failed to delete the price record ML FAILED TO CHANGE PRICE RECORD 0x0653 1619 Failed to change the price record Make sure that the date that identifies the price record is correct ML ARRAYS MUST HAVE SAME SIZE 0x0654 1620 The arrays must all have the same size This code causes this error Dim Time 2000 As Long Dim High 1000 As Single Dim Close 1000 As Single Writer AppendDataRecArray Dat Time Op High Low Cl Volume Openint Correct Dim Time 1000 As Long Dim High 1000 As Single Dim Close 1000 As Single Writer AppendDataRecArray Dat Time Op High Low Cl Volume Openin
50. n dLow Low quotation dClose Close quotation dVolume Volume dOpeniInterest Open interest Return Values The AppendDataRecArray function can raise the following errors File system errors ML INVALID DATE 0x0645 1605 ML NO DIRECTORY OPENED 0x0648 1608 ML INVALID TIME 0x064f 1615 ML ARRAYS MUST HAVE SAME SIZE 0x0654 1620 For extended error descriptions go to the MetaLib error codes section Example The following example creates price records arrays and saves these values to MetaStock files Private Declare Function GetTickCount Lib kernel32 As Long Private Sub AppendArray Dim Writer As New MLWriter Page 31 of 59 ChangeLastPriceRecord The ChangeLastPriceRecord overwrites the last record of a security file No new record is added to the security file HRESULT ChangePriceFields int iDate int iTime float fOpen float fHigh float flow float fClose float fVolume float fNewOpenint Parameters iDate The date must have the following format YYYYMMDD iTime The time must have the following format HHMMSS dOpen Open quotation Page 32 of 59 dHigh High quotation dLow Low quotation dClose Close quotation dVolume Volume dOpeniInterest Open interest Return Values The ChangePriceFields function can raise the following errors File system errors ML DATE NOT FOUND 0x0644 1604 ML INVALID DATE 0x0645 1605 ML NO DIRECTORY OPENED 0x0648 1608 ML INVALID TIME
51. ning price records of Microsoft If a file was found the file name will be displayed in a message box You can find a C sample in the C MetaLib Examples VC SecurityFinder directory On Error GoTo errorhandler Dim Finder As New MLSecurityFinder Finder bDisplaySearchDialog True Finder bScanSubDirectories True imaliaveleye V cu wise wiLlkokelsvenes que Finder FindSecurity MSFT c You can also use a ticker symbol MsgBox Finder SecFileName Do Finder FindNextSecurity MsgBox Finder SecFileName Loop Finder DestroySearchDialog Exit Sub errorhandler If Err Number 1603 Then Finder DestroySearchDialog Exit Sub MLSecurityFinder Properties bDisplaySearchDialog Set the fDisplaySearchDialog property to TRUE if you want that a progress dialog will appear during the search Don t forget to call the DestroySearchDialog function after the search bScanSubDirectories Set the fScanSubDirectories property to TRUE if you want that MetaLib scan trough all subdirectories of the directory specified in the sDirectory parameter of the FindSecurity function hSearchDialog Returns the window handle of the search dialog This property only contains a valid value if the bDisplaySearchDialog parameter was set to TRUE SecFileName The SecFileName property contains the filename of the specified security af
52. ord file The date is stored in the following format YYYYMMDD dSeAOpen Returns the open quotation array of a security price record file dSeAHigh Returns the high quotation array of security price record file dSeALow Returns the low quotation array of security price record file dSeAClose Returns the close quotation array of a security price record file Page 18 of 59 dSeAVolume Returns the volume array of a security price record file dSeOpen Returns the open quotation of the current security record dSeHigh Returns the high quotation of the current security record dSeLow Returns the low quotation of the current security record dSeClose Returns the close quotation of the current security record dSeVolume Returns the volume of the current security record iSeDate Returns the date of the current security record EX 20011214 The date is stored in the following format YYYYMMDD iSeRecordsLeft Returns the number of records that are stored in the specified security price record file deducting the number of price records that were loaded from the security file You can use this property for an exit condition in a loop iSeRecords Returns the number of records that are stored in the specified security price record file Fxxx dat or Fxxx mwd iSeTime Returns the time of the current price record iRound Returns all price records values rounded to a specified number of decimal places
53. rrors e File system errors e ML SECURITY NAME NOT FOUND 0 0643 1603 e ML DUPLICATE RECORD 0x0647 1607 For extended error descriptions go to the MetaLib error codes section Example This example changes the symbol of the security record DAX to the symbol DAX 30 The security name will not be changed Dim Writer As New MLWriter Writer OpenDirectory C MetaStock Writer ChangeSecurityRecord DAX j DAX 30 Writer CloseDirectory Page 35 of 59 CloseDirectory Call the CloseDirectory function if you have all data written to the master and security files The first and last date of the price records will be written to the master files HRESULT CloseDirectory void Return Values The CreateDirectory function can raise the following errors e File system errors For extended error descriptions go to the MetaLib error codes section CreateDirectory The CreateDirectory function creates a new directory where Master EMaster XMaster and security price record files Fxxx dat or Fxxx mwd can be stored Note If the directory already exists all files and subfolders of the directory will be deleted Use the CreateDirectoryEx function if you do not want to delete all the subfolders of a directory Writer CreateDirectoryEx C MetaStock false HRESULT CreateDirectory BSTR sDirectory Parameters sDirectory The name of the directory you want to create EX C MetaStock Dow Return Values The Cr
54. stroy Call this function to destroy the progress dialog HRESULT Destroy void Parameters This function has no parameters Return Value The Destroy function can raise the following exceptions e ML_PROGRESSBAR_FAILED 0x0663 1635 For extended error descriptions go to the MetaLib error codes section OffsetPos Advances the progress bar s current position by the increment specified by pos and redraws the bar to reflect the new position HRESULT OffsetPos int iPos Parameters iPos Amount to advance the position SetPos Sets the progress bar s current position as specified by pos and redraws the bar to reflect the new position The position of the progress bar is not the physical location on the screen but rather is between the upper and lower range indicated in SetRange Page 47 of 59 HRESULT SetPos int iPos Parameters iPos The new position of the progress bar SetRange Sets the upper and lower limits of the progress bar control s range and redraws the bar to reflect the new ranges HRESULT SetRange int iLower int iUpper Parameters iLower Specifies the lower limit of the range default is zero iUpper Specifies the upper limit of the range default is 100 SetStatus Call this function when you wish to update the status text HRESULT SetStatus BSTR sMessage Parameters sMessage A string that contains the status text to be displayed SetStep Specifies the st
55. t ML COPYRIGHT STRING TOO LONG 1621 0x0655 The copyright string is too long ML NO QUOTES AVAILABLE 1622 0X0656 No quoatations available Invalid symbol or wrong start and end date specified ML PRICE RECORD ALREADY EXISTS 0x0657 1623 The security record already exist in the security file You cannot add a record with the same date open high low close volume price again ML FAILED TO DIAL UP 0x065e 1630 A connection to the Internet could not be established Check if the connection name is correct Page 52 of 59 ML SERVER NOT CONNECTED 0x065f 1631 A connection to the Yahoo com server could not be established ML FAILED TO HANG UP 0x0660 1632 Failed to disconnect a RAS connection ML CONNECTION NAME NOT FOUND 0x0661 1633 The connection name doesn t exist Use a name that was returned by the Connections property ML PROGRESSBAR FAILED 0x0663 1635 The creation of the progress bar failed ML SEARCH DIALOG FAILED 0x0664 1636 The creation of the search dialog failed File system error codes ML DISK FULL 0x0672 1650 The disk is full ML TOO MANY OPEN FILES 0x0673 1651 The permitted number of open files was exceeded ML ACCESS DENIED 0x0674 1652 The file could not be accessed ML LOCK VIOLATION 0x0675 1653 There was an attempt to lock a region that was already locked ML SHARING VIOLATION 0x0676 1654 SHARE EXE was not loaded or a shared region was locked ML HA
56. tDirectory The directory where to write the files in MetaStock format If the directory does not exist a new directory will be created automatically sFileExtension The directory where to write the files in MetaStock format Return Values The AIQ2MetaStock function can raise the following exceptions e File system errors For extended error descriptions go to the MetaLib error codes section Example Dim Converter As new MLConverter Converter AIQ2MetaStock C AIQ C MetaStock TXT Page 45 of 59 MetaStock2CSV The MetaStock2CSV function converts all MetaStock security files of the specified directory to the CSV format The MetaStock2CSVEx function works the same way as the MetaStock2CSV function except that the Open Interest value will also be stored in the CSV file Therefore you should use the MetaStock2CSV function for converting stocks and the MetaStock2CSVEx function to convert Futures to CSV format HRESULT MetaStock2CSV BSTR sInputDirectory BSTR sOutputDirectory BOOL biIncludeTimeField BOOL bUseSecNamesAsFileName m Parameters sSourceDirectory The directory that contains the Metastock files Master Fx dat sOutputDirectory The directory where to write the CSV files bIncludeTimeField Set this value to true to store the time value in the CSV file bUseSecNamesAsFileName Set this value to true to use the security name as CSV file name instead of the symbol code Return Values The MetaStock2CSV
57. te Returns the last date that is stored in the security file fx dat file iLastTime Returns the last time that is stored in the seucirty file sCopyrightString Sets your own copyright string in the master EMaster XMaster and the price record files This string can be 46 characters long Page 27 of 59 sDirectory Returns the name of the currently opened MetaStock directory Read only sPeriodicity The period of the security is returned Daily Weekly Monthly or Intraday MLWriter Functions AppendintradaySecurity The AppendIntradaySecurity function adds an intraday security record to a directory Before you can use the AppendIntradaySecurity function you must call the CreateDirectory or OpenDirectory function If you want to add price records to this security record use the AppendDataRec function HRESULT AppendIntradaySecurity BSTR sSecuritySymbol BSTR sSecurityName INTERVAL enminterval int iStartTime int iEndTime Parameters sSecuritySymbol The ticker symbol for the security max 14 chars sSecurityName The name of the security max 45 chars enminterval The enmiInterval can have the following values None Tick Minute1 Minute5 Minute6 Minute10 Minute15 Minute20 Minute30 Minute60 iStartTime The start time The time must have the following format HHMMSS EX 183000 iEndTime The end time The time must have the following format HHMMSS EX 183000 Return Values The AppendIntr
58. ter you have called the FindSecurity or FindNextSecurity function and these functions didn t raise any error Page 44 of 59 SecName The SecName property contains the name of the specified security after you have called the FindSecurity or FindNextSecurity function and these functions didn t raise any error SecSymbol The SecSymbol property contains the symbol of the specified security after you have called the FindSecurity or FindNextSecurity function and these functions didn t raise any error sSearchDialogTitle Returns sets the window title of the search dialog This property only contains a valid value if the bDisplaySearchDialog parameter was set to TRUE ML Converter Interface AlQ2MetaStock The AIQ2MetaStock function converts all AIQ format files of a directory to the MetaStock format An EOD record in your AIQ text file should look like this NEE 11 21 97 11s 725 301 5 726 LA 3 98 11 ASS 2094 727 9 Symbol Periodicity d m w Date DD MM YY Open High Low Close Volume Open interest An intraday record in your AIQ text file should look like this AKAME 6 20901920 379 1920 3905900 309270 2500 Symbol Periodicity i Date DD MM YY Time HHMM Open High Low Close Volume Open interest HRESULT AIQ2MetaStock BSTR sSourceDirectory BSTR sOutputDirectory BSTR sFileExtension Parameters sSourceDirectory The directory that contains the AIQ files sOutpu
59. tyByName function to specify where the price record should be written 2 Call the OpenSecurityByFilename function of the MLWriter interface The price records will be written to the file you have specified in the BSTR sFilename parameter 3 Call the OpenDirectory function of the MLWriter interface Use the AppendSecurity function to add a security to the master file Now you can call the AppendDataRec of the MLWriter interface to add a price record to the selected security file It is recommended that you call the CloseDirectory afterwards Page 26 of 59 MLWriter Properties bDateExists Returns True if the specified date exists The date has the format YYYYMMDD Example If Writer bDateExists Date Then MsgBox Date exists End If If Not Writer bDateExists Date Then MsgBox Date does not exists End If blsUsed Returns TRUE if the directory you want to open is used by another program Example Dim Writer as New MLWriter Dim bIsUsed as Boolean bIsUsed Writer bIsUsed C MetaStock bSymbolExists Returns TRUE if the specified symbol exists Example If Writer bSymbolExists Symbol Then MsgBox Symbol exists End If If Not Writer bSymbolExists Symbol Then MsgBox Symbol does not exists End If iFields Sets the field size of the security This value can be between 4 Tick and 8 Note By default MetaLib sets the field size of the price record file iLastDa
60. ype Library 10 C Program Files Common Files Roxio Shared 9 0 merge 1 0 Type Library 10 C Program Files Microsoft Works wkwzmrg DLL 50 c Metal ib ReleaseMinDependency Metalib dil MGiDiagnostics 1 0 Library 1 0 C Program Files Common Files Roxio Shared 9 0 MGlFormatLoaderDVDB 1 0 1 0 C Program Files Roxio Roxio MyDVD Basic v9 Vi 1 0 1 0 C Program Files Roxio Roxio MyDVD Basic bs mene Ss Arrar 1 an CA Dennen nen nf 3 Double click on the MetaLib 5 0 entry 4 The MetaLib entry will appear in the Selected Components list box 5 Click on OK For easier use it is recommended that you write the statement using METALIBLib at the top of each source code file where you want to use the DLL Use the new statement to create a new instance of an interface MLReaderClass lReader new MLReaderClass MLWriter lWriter new MLWriterClass If you do not use the using METALIBLib statement you have to declare the interfaces as shown below METALIBLib MLReaderClass lReader new METALIBLib MLReaderClass METALIBLib MLWriter lWriter new METALIBLib MLWriterClass Take a look at the C example that are located in the C Program Files Metalib Examples folder for more details How to add MetaLib to your Delphi
Download Pdf Manuals
Related Search
Related Contents
Mémoire - L`UTES manuel d`utilisation The Singing Machine SMB-635 CD Player User Manual Le roman photo multimédia, un projet d`écriture collective et d Decoding GE AST05 Air Conditioner User Manual Black Box G.703 NTU w/10BaseT User Manual TEKTRONIX DTG5334 Datasheet User Guide 平成 24 年 6 月 21 日 独立行政法人水産総合 Copyright © All rights reserved.
Failed to retrieve file