Metastock Developer Kit
Metastock Developer Kit
Metastock Developer Kit
Developers Kit
For MetaStock Solution Providers
Version 9.1
Printed in the USA
All Rights Reserved
Copyright 1985-2005
Equis International
90 South 400 West
Suite 620
Salt Lake City, UT USA
84101
http://www.equis.com
The MetaStock Developers Kit (Software) and accompanying documentation (MetaStock Developers Kit
User's Manual) are licensed, not sold, to you. By opening the sealed package and/or using the Software, you
indicate your acceptance of the Equis Software License Agreement that is included with the original package.
The DownLoader and Smart Charts are trademarks of Equis International. Equis and MetaStock are
registered trademarks of Equis International. Microsoft, MS-DOS, Windows, Windows NT, Win32, Visual
C++, Developer Studio, and Visual Basic are trademarks of Microsoft Corporation. Borland is a registered
trademark of Inprise Corporation. Delphi is a trademark of Inprise Corporation. PowerBASIC is a registered
trademark of PowerBASIC, Inc.
Except as permitted by law, no part of this document may be reproduced or transmitted by any process or
means without the prior written consent of Equis International (Equis). Equis, by publishing this document,
does not guarantee that any information contained herein is and will remain accurate or that use of the
information will ensure correct and faultless operation of the relevant product or service. Equis provides its
products and services as tools to be used by investors who are aware of the risk inherent in securities trading,
not as recommendations to buy or sell. Equis, its agents, affiliates, and employees shall not be held liable to
or through any user for any loss or damage whatsoever resulting from reliance on the information contained
within this document or through the use of Equis products or services.
9/23/05
9 8 7 6 5 4 3 2 1
IP
MetaStock
Table of Contents i
Table of Contents
Introduction 1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Typography Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Supported Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Installed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Modifying the MetaStock User Interface 5
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Using the EqCustUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Command Line Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Formula Organizer Enhancements 13
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Using the Formula Organizer to Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Using the Self-extracting Installation File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
DDE Data Interface 17
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Running EqDdeSrv.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
System Topic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Microsoft Excel Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Simple C Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Suggested Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
MetaStock External Functions (MSX) 25
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
MSX DLL Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Getting Assistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Function Prototype Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Initialization Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Calculation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ii Table of Contents MetaStock
Variable Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Initialization Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Calculation Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Function Argument structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Creating an MSX DLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Microsoft Visual C++ 4.x, 5.0, and 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Borland C++ Builder 4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Borland C++ 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Borland Delphi 3.0, 4.0, and 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
PowerBASIC/DLL 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Naming your DLL and Calculation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Debugging Your MSX DLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
General Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Microsoft Visual C++ 4.x, 5.0, and 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Borland C++ Builder 4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Borland C++ 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Borland Delphi 3.0, 4.0, and 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
PowerBASIC/DLL 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Testing Your DLL With MSXTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Stress Testing Your DLL Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Automating MSXTest From Your IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Testing Your DLL With MetaStock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Programming Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Data Storage and Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Things to Remember . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
User Interface Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Tech Note 1 Using MSFL in an MSX DLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
MSX Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Sample DLL Programs 63
C Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Delphi Pascal Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
PowerBASIC/DLL Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
MetaStock File Library (MSFL) 75
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Whats New . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Application Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Delphi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PowerBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Securities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Price Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Composites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Multi-user Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Reserved File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
MetaStock
MetaStock
Introduction 1
Introduction
Overview
The MetaStock
Typography Conventions
The following typographic conventions are used throughout this manual:
System Requirements
Windows NT 4.0 (Service Pack 6a or higher)/
Windows 2000 (Service Pack 1 or higher)/
Windows XP
166 MHz Pentium CPU
32 MB of RAM
50 MB of free hard disk space
Setup
1. Insert the Program CD into your drive. The setup program should start automatically.
If the auto-run feature of Windows isn't enabled on your system,
a. Click Start and choose Run.
b. Type D:\SETUP.EXE in the Open box and click OK.
(D represents the letter assigned to your CD-ROM drive. If your drive is
assigned a different letter, use it instead of D.)
2. Follow the on-screen instructions. You will be prompted to enter a Setup Key.
Your Setup Key is found on the back of the CD case.
Supported Compilers
The MetaStock Developers Kit supports the following compilers:
Borland
/DLL Version 6
Typeface Significance
Monospaced t ype Program code.
Italic Monospace Filenames
Sans Serif Text in the program interface
(Bold indicates buttons)
ALL CAPS Mnemonics such as error codes, messages and defined values.
Italics Function names, variable names, structure names or identifiers.
(This type is also used to emphasize certain words.)
MetaStock
Introduction 3
Installed Files
After installing, the following directories and files should exist in the installation
directory. Below is a short description of each file and directory.
Directory/File Description
UI Contains eqcustui.exe (the Equis Custom User Interface application) and
ReadMe.Doc which contains information provided since the printing of this manual.
MSFL\ DATA This directory contains sample MetaStock price data.
MSFL\ DLL
msf l 91. dl l The release version of the MSFL DLL.
msf l 91d. dl l The debug version of the MSFL DLL.
MSFL\ DEF
msf l . def The module definition file for the MSFL DLLs
MSFL\ I NCLUDE
msf l . h The C header file containing the MSFL defines, structures and function prototypes.
msf l ut i l . h The prototypes for a small collection of helpful C++ functions.
msf l ut i l . cpp A small collection of helpful C++ functions.
msf l . bas The Microsoft Visual Basic module containing the MSFL function and type declares.
msf l ut i l . bas A Microsoft Visual Basic module containing helpful routines.
msf l . pas The Delphi unit containing the MSFL constants, records and function declarations.
msf l . i nc The PowerBASIC module containing the MSFL function and type declares.
MSFL\ LI B\ BC
msf l 91. l i b The release link library for Borland C++ Builder 4 compiler.
msf l 91d. l i b The debug link library for Borland C++ Builder 4 compiler.
MSFL\ LI B\ GCC
msf l 91. l i b The release link library for the gcc 2.9.5.2 compiler.
msf l 91d. l i b The debug link library for the gcc 2.9.5.2 compiler.
MSFL\ LI B\ VC
msf l 91. l i b The release link library for Microsoft Visual C++ 6.0 compiler.
msf l 91d. l i b The debug link library for Microsoft Visual C++ 6.0 compiler.
MSFL\ SAMPLES\ BC The sample application for Borland C++ Builder 4 compiler.
MSFL\ SAMPLES\ C- CONSOLE A C/C++ sample console application for the Borland C++ Builder 4, gcc 2.9.5.2, and
Microsoft Visual C++ 6.0 compilers.
MSFL\ SAMPLES\ DELPHI The sample application for Borland Delphi 4.
MSFL\ SAMPLES\ PB The sample application for PowerBASIC/DLL 6.0.
MSFL\ SAMPLES\ VB The sample application for Microsoft Visual Basic 6.0.
MSFL\ SAMPLES\ VC The sample application for the Microsoft Visual C++ 6.0 compiler.
MSX Contains MSXTest.exe, sample DLLs, sample data, and ReadMe.Doc containing
additional information provided since the printing of this manual.
MSX\ C Samples and templates for Microsoft Visual C++ (Versions 4.0 and above), and
Borland C++ (Versions 5.0 and above).
MSX\ DELPHI Samples and templates for Borland Delphi Versions 3, 4 and 5.
MSX\ PBasi c Samples and templates for PowerBASIC/DLL Version 6.
4 Introduction MetaStock
Getting Help
Due to the complexity of the programming languages and development environments,
Equis International is only able to provide minimal technical support for the MetaStock
Developers Kit. We will help you in understanding how to use the MetaStock
Developers Kit, but we cannot aid in writing or debugging your application or DLL.
This manual explains the use of the MetaStock Developers Kit, but not the programming
techniques required to effectively use it. The sample applications can be a good source of
information as well as an excellent starting point.
CAUTION: Failure to follow the programming guidelines may result in the corruption of other
MetaStock variables and/or loss of the users data. Equis International shall not be
responsible for any damages of any type caused by the MetaStock Developers Kit.
Equis International is committed to enhancing the MetaStock Developers Kit. If you
are having a problem directly related to the Developers Kit, you may contact Equis by
mail or by the Internet.
By Mail
Equis International
MS Dev Kit Support
90 South 400 West, Suite 620
Salt Lake City, UT 84101
By Internet
msdevkit@equis.com
When contacting Equis by Internet, please include the module you are working with in
the subject line of your e-mail message (For example, MSX, MSFL, etc.).
MetaStock
The following is a C/C++ example of how to use the Cr eat ePr ocess function to
modify the MetaStock user interface.
BOOL bPr ocessCr eat ed;
STARTUPI NFO si ;
PROCESS_I NFORMATI ON pi ;
si . cb = si zeof ( si ) ;
si . l pReser ved = NULL;
si . l pTi t l e = NULL;
si . dwFl ags = STARTF_USESHOWWI NDOW;
si . wShowWi ndow = SW_SHOWNORMAL;
si . cbReser ved2 = 0;
si . l pReser ved2 = NULL;
/ / Spawn EqCust UI t o modi f y t he Met aSt ock user i nt er f ace
bPr ocessCr eat ed = Cr eat ePr ocess (
_T( "c: \ \ sour ce\ \ equi s apps\ \ eqcust ui \ \ debug\ \ eqcust ui . exe") ,
_T( "EqCust UI . exe \ "Tool bar . Add( www. equi s. com, Equi s on t he
web) \ "") ,
NULL,
NULL,
FALSE,
NORMAL_PRI ORI TY_CLASS,
NULL,
NULL,
&si ,
&pi ) ;
/ / Wai t f or EqCust UI t o f i ni sh
i f ( bPr ocessCr eat ed)
Wai t For Si ngl eObj ect ( pi . hPr ocess, 5000) ;
Note: The command line must be enclosed in quotes (" ") if spaces are used. While this is
optional if there are no spaces in the command line, it is recommended that the command
line always be enclosed in quotes to avoid problems in the future.
The MetaStock user interface is modified by specifying an object.command pair on the
utility's command line. The keywords Toolbar and Menu are the only objects accepted
by the EqCustUI utility. The Toolbar object accepts the commands Add and Delete.
The Menu object accepts the commands AddItem, DeleteItem, AddPopupItem, and
DeletePopupItem. Objects and commands must be separated by a period. For example,
Toolbar.AddItem is valid whereas ToolbarAddItem is not. The EqCustUI utility does
not allow the third-party developer to specify or change the order of buttons and menu
items.
IMPORTANT: The EqCustUI utility is not copied to the end user's computer when they install
MetaStock. For this reason the EqCustUI utility must be included with each third-party
solution that modifies the MetaStock user interface. Failure to do so will cause the third-
party setup program to fail as it will not be able to modify the MetaStock user interface.
It should also be noted that if the EqCustUI utility is temporarily copied to the end user's
hard drive, it must be deleted when the third-party setup program finishes.
MetaStock
Toolbar.Delete
Tool bar . Del et e( <Command>)
Parameters
Command Specifies the action (executable file, internet URL, document, etc.) that is
associated with the button to delete.
Remarks
This removes a button from the MetaStock Custom toolbar.
The toolbar is searched until a button is found that is associated with this file.
If a button is found it will be deleted.
IMPORTANT: Third-party developers should only delete the buttons they have created on the Custom
toolbar. A third-party developer should never delete another developer's button on the
toolbar. Doing so is a violation of the license agreement.
Example
EqCust UI "Tool bar . Del et e( www. mycompany. com) "
Menu.AddItem
Menu. AddI t em( <Locat i on>, <Menu>, <Command>)
Parameters
Location Specifies the placement of the new menu item. Please note that MetaStock
uses two different and distinct menus. The first menu (Main) is used when
a chart is not opened on the screen, whereas the second menu (Chart) is
used when a chart is opened on the screen. For this reason menu items
must be added to both the Main menu and the Chart menu to be visible at
all times.
The following are the different locations available.
Menu Specifies the string to be placed on the menu.
Command Specifies the action that is associated with this menu item. Any syntax that
can be specified in the Windows run dialog (Start> Run) can be specified
here. This includes executable files, internet URLs, and documents that
are associated with a valid program on the system.
MetaStock supports several predefined literals that have special meaning.
These literals will be replaced with the appropriate value when the user
selects the menu item. The greater-than and less-than (< >) characters
must be included.
Placement Location (The menu is located: )
Main-Tools On the Tools menu when no chart is opened.
Main-Help On the Help menu when no chart is opened.
Chart-Tools On the Tools menu when a chart is opened.
Chart-Help On the Help menu when a chart is opened.
MetaStock
ParentMenuSpecifies the name of the parent menu item. Multiple levels can be nested
by using the forward slash (/) character. However, parent menus may not
begin or end with the / separator character. For example,
My company/Support would be a valid parent menu; while
My company/Support/ is not valid.
Menu Specifies the string of the item that is to be deleted.
Command Specifies the action that is associated with the menu item to be deleted
Remarks
Removes a menu from a popup (nested) menu.
If the popup menu is empty after the deletion it will be removed.
All four command parameters must be specified to be able to delete a menu item.
MetaStock must be restarted for menu modifications to take effect.
IMPORTANT: Third-party developers should only delete the menu items that they have added.
A third-party developer should never delete another developer's menu item.
Doing so is a violation of the license agreement.
Example
EqCust UI "Menu. Del et ePopupI t em( Mai n- Hel p, My company, My
company on t he web, www. mycompany. com) "
Command Line Switches
The following is a list of command line switches that the EqCustUI utility supports.
/h Help. Displays a help screen. No other switches or commands are processed.
/q Quiet. Prevents the EqCustUI utility from displaying error messages.
Errors
The Windows API function GetExitCodeProcess can be used to retrieve the EqCustUI
exit code. For batch files, the ERRORLEVEL command can be used to change
program flow.
The following is a list of possible exit codes that can be returned by EqCustUI.
Returned Value Meaning
0 The operation was successful. No error was encountered.
1 Cannot open the custom toolbar storage file. It is either locked or
MetaStock is not installed.
2 Cannot open the custom menu storage file. It is either locked or
MetaStock is not installed.
3 Out of memory.
4 Cannot add the button to the toolbar.
5 Cannot delete the button from the toolbar.
6 Cannot find the button on the toolbar.
7 Cannot add menu item.
8 Cannot delete menu item.
9 Cannot create popup (nested) menu.
10 Cannot open popup (nested) menu.
11 Cannot delete popup (nested) menu.
12 Cannot open the specified program, document, or internet resource.
13 Cannot read a file.
14 Cannot write to a file.
MetaStock
CAUTION: Formula Organizer is not backward compatible, e.g. tools exported by the Formula
Organizer cannot be imported by an earlier version of the Formula Organizer.
For example, if you export using 7.03, a user with 7.01 cannot import your file. If you
export using 7.2, no user with 7.0x can import your file. The self-extracting installer will
not launch any version of Formula Organizer previous to 7.0.
Using the Formula Organizer to Export
When the Developers Kit is installed with MetaStock 7.0 or above, additional dialogs
are included in the Formula Organizer's export process. You will be prompted to:
Choose formulas to export,
Choose templates to export,
Choose DLLs to export,
Include a copyright information text file,
Create a self-extracting installation file,
Password-protect the formulas, and
Password-protect the self-extracting installation file.
To Export using the Formula Organizer
1. Start any one of MetaStock's formula tools (Indicator Builder, System Tester,
The Explorer, Expert Advisor).
For example, select Tools> Indicator Builder to start the Indicator Builder.
2. Click the Organizer button.
Password protect exported components
! !
Password protect self-extracting install
!
Copyright notice on self-extracting install
!
Formula Organizer Function
without
MDK
with
MDK
Choose Indicator Builder
MetaStock
Note: If you created a self-extracting installation file, you may enter a password for the file in this
dialog. If you did not choose to create a self-extracting installation file, this option will not
be displayed in the dialog. The user will be prompted for the installation password
immediately after the installation file is run.
11. Click Finish to complete the export process.
Using the Self-extracting Installation File
The self-extracting installation file that you created (FOSetup.exe) contains all the
files that were exported. You may rename FOSetup.exe to any other name you wish
(e.g., SuperTools.exe) using Windows Explorer. Be sure to leave the .exe extension.
When the user runs FOSetup.exe, a temporary folder is created, the files are extracted
to it, and the users copy of the Formula Organizer (FormOrg.exe) will be executed to
import the files. If the self-extractor detects multiple versions of FormOrg.exe it will
require the user to select the desired version to run. After the import, the temporary
folder will be removed.
If any MSX DLLs are to be imported, they are copied to a temporary folder called
~MSXIMPORTDLLS~ located under the users External Function DLLs folder.
If MetaStock is running when FormOrg is finishing, FormOrg sends a signal to
MetaStock to load the new DLLs. Otherwise, when MetaStock starts up it checks for
MSX DLLs in this folder and, if any exist, they are moved to the
External Function DLLs folder.
The password that can be applied to a self-extracting install allows you to distribute
your tools via a web page or email. The compressed tools are encrypted and require the
correct password to be extracted.
Installing the self-extracting installation file
Installation of the self-extracting installation file follows theis process. Once the process
is started, only steps 2 and 5 require user interaction.
1. The system is searched for formorg.exe. If multiple versions are detected, the user is
prompted to choose one.
2. If the installation file has been password protected, the user is prompted to enter the
password.
3. A temporary folder is created to hold the installation files.
4. The installation files are unzipped into the temporary folders.
5. If a copyright file was included, the contents of that file are displayed. The user must
click the OK button to proceed.
6. The formula files are imported by formorg.exe.
7. The temporary folders and their contents are removed.
MetaStock
Interface
The Service, or Application, string is always EQDDESRV. Topic is generally the
security or index symbol, with the exception of the reserved topic SYSTEM. A
discussion of the System topic appears later in this document (see page 20).
Note: Keep in mind that security and index symbols may be vendor-specific. If your client
application contains hard-coded security or index symbols, it may be limited to working only
with the data vendor you are using.)
Item is one of the following strings:
Note: EqDdeSrv always returns price data as a formatted string (CF_TEXT type). With the
exception of the Date and Time strings (mm/dd/yyyy and hh:mm), all strings are formatted
as a floating point number with a maximum of four decimal places.
Running EqDdeSrv.exe
EqDdeSrv can be started by clicking on the Equis DDE Server shortcut in the Equis
program folder. If you want your application to start EqDdeSrv.exe, you can locate it
by examining the registry at: HKEY_CURRENT_USER\ Sof t war e\ Equi s\ Common.
Beginning with version 7.0 of MetaStock, there will be a registry key below Common
for each version that is currently installed (i.e. 7. 0). Below the version number is a
registry key Fi l e Pat hs which contains a string Pr ogr amPat h.
The ProgramPath string indicates the folder where the MetaStock executables are
located. Append the folder \Servers to the program path and verify the existence of
EqDdeSrv.exe.
CAUTION: If there are multiple versions of MetaStock installed, your application should display a
dialog with each of the versions and allow the user to pick the correct one.
Note: Before starting EqDdeSrv from your program, attempt to establish a connection with it to
determine if it is already running. Arbitrarily running EqDdeSrv.exe when it is already
running will cause EqDdeSrv to display its summary window.
OPEN Openi ng pr i ce
HIGH Hi gh pr i ce so f ar t oday
LOW Low pr i ce so f ar t oday
LAST Lat est pr i ce t oday
PREVCLOSE Pr evi ous t r adi ng day s cl osi ng ( l ast ) pr i ce
CHANGE LAST - PREVCLOSE
TOTALVOL Tot al vol ume t oday
YDTOTALVOL Tot al vol ume yest er day ( f ut ur es onl y)
TRADEVOL Vol ume of l ast t r ade
( t hi s val ue wi l l be 0 wi t h some dat a vendor s
unt i l t he f i r st t r ade occur s af t er r equest i ng
val ues f or t he speci f i c secur i t y)
DATE Last t r ade dat e ( mm/ dd/ yyyy)
TIME Last t r ade t i me ( hh: mm)
OPENINT Open i nt er est ( i f appl i cabl e, ot her wi se 0)
BID Bi d
ASK Ask
BIDSIZE Bi d si ze
ASKSIZE Ask si ze
MetaStock
System Topic
The System topic allows a DDE Client to obtain certain information about the DDE
Server. #def i ne entries for the standard system topics are included in the ddeml.h
file that accompanies most Windows compilers. Although use of the #def i ne is
recommended, the actual string constants are presented here. Only the Topic and Item
fields are shown in the table. The following System topics are supported by EqDdeSrv:
Examples
Microsoft Excel Example.
Microsoft Excel has the ability to act as a general DDE client. You can specify a DDE
hot-link in any cell by entering a formula of the form:
=Ser ver | ' Topi c' ! I t em
The server is separated from the topic by the vertical solid bar character, and the topic is
separated from the item by an exclamation point. For example, to observe the
constantly updated last price for Microsoft, you would enter the following formula in
any cell:
=EQDDESRV| ' MSFT' ! LAST
Notes:
The case of the topic is important only if the data vendor is case sensitive.
The date and time strings are converted by Excel to Julian dates. You must apply
Excel date and time formatting to view these fields in MM/DD/YYYY format.
The Excel screen shown on the next page has a DDE formula in each cell that is
displaying a price value. The %Chg column is calculated from the LAST and
PREVCLOSE columns. All values update in real time, and the pie chart at the bottom
constantly reflects the changes in the TRADEVOL column. The cursor is on cell E3,
and you can observe the formula in the Excel edit line:
Topic Item Returned Data
System Topics Tab delimited list of all securities with active connections.
System SysItems Tab delimited list of all supported System Topics: Topics,
SysItems, Status, Formats, and TopicItemList.
System Status EqDdeSrv always returns Ready.
System Formats EqDdeSrv always returns Text. CF_TEXT is the only format
supported by EqDdeSrv.
Security
Symbol
TopicItemList Note: A security symbol is specified in the Topic field.
Returned data is a tab delimited list of all the price fields that have
an active advise request by any DDE Client. For example, if two
DDE clients have hot-links to Microsoft stock, and the first is
watching LAST and TRADEVOL, and the second is watching
LAST and OPEN, the returned data would by a tab delimited
string containing OPEN, LAST, and TRADEVOL.
MetaStock
Simple C Example
/ * EqDDeDemo - Thi s DDE cl i ent i s a shor t exampl e of how t o obt ai n pr i ce
dat a f r omt he Equi s DDE Ser ver ( EQDDESRV. EXE) .
*/
#i ncl ude <wi ndows. h>
#i ncl ude <ddeml . h>
#def i ne WM_USER_I NI T_DDE ( WM_USER + 1) / / Event t o i ni t i al i ze DDE
/ / Wi ndow cal l back
LRESULT CALLBACK WndPr oc ( HWND, UI NT, WPARAM, LPARAM) ;
/ / DDE cal l back
HDDEDATA CALLBACK DdeCal l back ( UI NT, UI NT, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD) ;
DWORD i dI nst ; / / gl obal pr ogr ami nst ance
HCONV hConv; / / gl obal handl e t o DDE conver sat i on
HWND hWnd; / / gl obal handl e t o wi ndow
char szVal ue[ 20] ; / / r ecei ves val ues obt ai ned f r omDDE ser ver
char szAppName[ ] = "EqDdeDemo";
i nt WI NAPI Wi nMai n( HI NSTANCE hI nst ance,
HI NSTANCE hPr evI nst ance,
LPSTR l pCmdLi ne,
i nt nCmdShow)
{
MSG Msg;
WNDCLASSEX WndCl ass;
st r cpy( szVal ue, "<wai t >") ; / / I ni t i al i ze val ue st r i ng
/ / Fi l l t he Wi nd Cl ass st r uct ur e
WndCl ass. cbSi ze = si zeof ( WndCl ass) ;
WndCl ass. st yl e = CS_HREDRAW| CS_VREDRAW;
WndCl ass. l pf nWndPr oc = WndPr oc;
WndCl ass. cbCl sExt r a = 0;
WndCl ass. cbWndExt r a = 0;
WndCl ass. hI nst ance = hI nst ance;
WndCl ass. hI con = LoadI con( NULL, I DI _APPLI CATI ON) ;
WndCl ass. hCur sor = LoadCur sor ( NULL, I DC_ARROW) ;
WndCl ass. hbr Backgr ound = ( HBRUSH) Get St ockObj ect ( WHI TE_BRUSH) ;
WndCl ass. l pszMenuName = NULL;
WndCl ass. l pszCl assName = szAppName;
WndCl ass. hI conSm = LoadI con( NULL, I DI _APPLI CATI ON) ;
Regi st er Cl assEx ( &WndCl ass) ;
/ / har d- code a smal l wi ndow si ze & l ocat i on f or demo pur poses
hWnd = Cr eat eWi ndow ( szAppName, "Equi s DDE Cl i ent Demo",
WS_OVERLAPPEDWI NDOW,
100, 100, 250, 70,
NULL, NULL, hI nst ance, NULL) ;
ShowWi ndow ( hWnd, nCmdShow) ;
Updat eWi ndow ( hWnd) ;
/ / I ni t i al i ze t he DDEML l i br ar y
i f ( DdeI ni t i al i ze ( &i dI nst , ( PFNCALLBACK) &DdeCal l back,
APPCLASS_STANDARD | APPCMD_CLI ENTONLY, 0L) )
{
MessageBox ( hWnd, "Unabl e t o i ni t i al i ze DDE cl i ent . ",
szAppName, MB_I CONEXCLAMATI ON | MB_OK) ;
Dest r oyWi ndow( hWnd) ;
r et ur n FALSE;
}
/ / St ar t t he DDE conver sat i on
SendMessage( hWnd, WM_USER_I NI T_DDE, 0, 0L) ;
whi l e ( Get Message( &Msg, NULL, 0, 0) )
{
Tr ansl at eMessage( &Msg) ;
Di spat chMessage( &Msg) ;
}
DdeUni ni t i al i ze( i dI nst ) ;
r et ur n Msg. wPar am;
MetaStock
Create functions that can be used by Custom Indicators, System Tests, Explorations,
and Experts.
Distribute your compiled MSX DLL to other users.
Things that you cannot do with an MSX DLL
Things that you cannot do with an MSX DLL include:
Manipulate GUI functions, including plotting and user dialogs.
Access the standard MetaStock built-in functions from within your DLL.
Getting Assistance
Due to the complexity of programming languages and development environments,
Equis is able to provide only minimal technical support for the MSX API.
We will help with understanding how to use the MSX API, but we cannot aid in writing
or debugging your DLL.
Important Notes
This manual explains the use of the MSX API and provides several examples of how
to use it correctly.
It is imperative that you read this entire chapter, in the order presented, to successfully
create an MSX DLL.
It is essential that you follow all specified programming guidelines and API
requirements. External DLLs receive pointers to data structures allocated by
MetaStock. Failure to follow the MSX programming guidelines may result in your
DLL modifying memory outside the boundaries of the defined data structures,
potentially corrupting other MetaStock variables and causing loss of the users data.
Note: Equis shall not be responsible for any damages of any type caused by MSX DLLs.
For more information on Technical Support for the MetaStock Developers Kit,
see page 4.
Overview
MetaStock will automatically recognize and load any MSX DLL that exists in the
External Function DLLs folder, which is a subfolder of the MetaStock system
folder.
An MSX DLL implements one or more external functions that can be called from
within any formula in MetaStock. In order to implement an external function, an
MSX DLL must perform two basic tasks:
Define the function syntax including the function name, number of arguments, and
argument types.
Calculate the results of the function when it is called and return those results to
MetaStock.
Each external function has a unique name that identifies the function within a
MetaStock formula. The syntax for each function can define up to nine arguments that
supply numeric data for calculations or control the behavior of the calculation.
MetaStock users call external functions from within formulas by using the External
Formula function:
Ext Fml ( "DLL Name. Function Name" , ar g1, , ar gn)
As an example, if an MSX DLL named MyDLL implements a function called
MyFunction, which accepts a single price data argument, the function can be called
from any MetaStock formula by the following:
Ext Fml ( "MyDLL. MyFunct i on", cl ose)
MetaStock
MSXNthFunction
This function is called once during initialization for each external function specified by
the MSXInfo call. See MSXInfo (page 27) for more details on using this function.
C
BOOL __st dcal l MSXNt hFunct i on ( i nt a_i Nt hFunc,
MSXFuncDef *a_psFuncDef )
Delphi Pascal
f unct i on MSXNt hFunct i on ( a_i Nt hFunc: I nt eger ;
var a_psFuncDef : MSXFuncDef )
: LongBool ; st dcal l ;
PowerBASIC/DLL
FUNCTI ON MSXNt hFunct i on SDECL ALI AS MSXNt hFunct i on ( _
BYVAL a_i Nt hFunc as LONG, _
a_psFuncDef AS MSXFuncDef PTR) EXPORT AS LONG
Parameters
Return Values
MSX_SUCCESS if successful
MSX_ERROR for internal error
MSXNthArg
This function is called once during initialization for each argument specified for each
external function. If none of the external functions have arguments this function will not
be called and is not required.
C
BOOL __st dcal l MSXNt hAr g ( i nt a_i Nt hFunc,
i nt a_i Nt hAr g,
MSXFuncAr gDef *a_psFuncAr gDef )
Delphi Pascal
Funct i on MSXNt hAr g ( a_i Nt hFunc: I nt eger ;
a_i Nt hAr g: I nt eger ;
var a_psFuncAr gDef : MSXFuncAr gDef )
: LongBool ; st dcal l ;
PowerBASIC/DLL
FUNCTI ON MSXNt hAr g SDECL ALI AS MSXNt hAr g _
BYVAL a_i Nt hFunc AS LONG, _
BYVAL a_i Nt hAr g AS LONG, _
a_psFuncAr gDef AS MSXFuncAr gDef PTR)
EXPORT AS LONG
Parameters
a_iNthFunc The zero-based index indicating which functions information is
requested.
a_psFuncDef Pointer to the MSXFuncDef data structure (page 32) to be filled in with
external function information..
a_iNthFunc The zero-based index indicating which functions information is
requested.
a_iNthArg The zero-based index indicating which argument of the specified
functions information is requested.
MetaStock
Calculation Functions
All external calculation functions have the following prototype:
C
BOOL
__st dcal l
<FuncName> ( const MSXDat aRec *a_psDat aRec,
const MSXDat aI nf oRecAr gsAr r ay *a_psDat aI nf oAr gs,
const MSXNumer i cAr gsAr r ay *a_psNumer i cAr gs,
const MSXSt r i ngAr gsAr r ay *a_psSt r i ngAr gs,
const MSXCust omAr gsAr r ay *a_psCust omAr gs,
MSXResul t Rec *a_psResul t Rec)
Delphi Pascal
f unct i on
<FuncName> ( const a_psDat aRec: PMSXDat aRec;
const a_psDat aI nf oAr gs: PMSXDat aI nf oRecAr gsAr r ay;
const a_psNumer i cAr gs: PMSXNumer i cAr gsAr r ay;
const a_psSt r i ngAr gs: PMSXSt r i ngAr gsAr r ay;
const a_psCust omAr gs: PMSXCust omAr gsAr r ay;
var a_psResul t Rec: MSXResul t Rec)
: LongBool ; st dcal l ;
PowerBASIC/DLL
FUNCTI ON
<FuncName> SDECL ALI AS <FuncName> _
( a_psDat aRec AS MSXDat aRec PTR, _
a_psDat eI nf oAr gs AS MSXDat aI nf oRecAr gsAr r ay PTR, _
a_psNumer i cAr gs AS MSXNumer i cAr gsAr r ay PTR, _
a_psSt r i ngAr gs AS MSXSt r i ngAr gsAr r ay PTR, _
a_psCust omAr gs AS MSXCust omAr gsAr r ay PTR, _
a_psResul t Rec AS MSXResul t Rec PTR) EXPORT AS LONG
Note: <FuncName> is the name of your function. The name listed in the EXPORTS section or
ALIAS string of your code and the name returned by the MSXNthFunction (page 28) must
exactly match the spelling and case of this function name.
Parameters
Cautions:
Do not write values to the a_psResultRec->psResultArray->pfValue array beyond the
index value of a_psDataRec->sClose.iLastValid. Writing beyond that point will
corrupt MetaStock system memory, and may cause a loss of user data.
MetaStock does not support iLastValue indexes greater than the iLastValue index of
the Close data array. See page 58 for more details.
a_psDataRec The read-only data structure that contains all available price data and
security details. This structure is always passed to all calculation
functions, regardless of their defined argument lists. (page 36).
a_psDataI nfoArgs The read-only data array arguments expected by the function. (page 38).
a_psNumericArgs The read-only Numeric (float) arguments expected by the function.
(page 39).
a_psStringArgs The read-only String arguments expected by the function. (page 39).
a_psCustomArgs The read-only custom argument IDs expected by the function.
(page 39).
a_psResultRec A data structure containing the data array that your function will fill with
data to be returned to MetaStock. Be sure to set both iFirstValid and
iLastValid in a_psResultRec->psResultArray before returning from
your function.
MetaStock
Initialization Structures
The following structures are used to communicate between MetaStock and the MSX
API initialization functions. These structures allow the MSX DLL to give MetaStock
information regarding function names and function syntax information.
Note: All data structure examples are shown using C syntax, and are found in the MSXStruc.h
file included with the MetaStock Developers Kit. Corresponding data structure definitions
for Delphi Pascal and PowerBASIC/DLL can be found in the MSXStruc.pas and
MSXStruc.bas files, respectively.
MSXDLLDef structure
This structure contains fields that define the DLL copyright, the number of external
functions exported by the DLL, and the MSX version number. It is used exclusively by the
MSXInfo function. See MSXInfo (page 27) for more details on using this function.
t ypedef st r uct
{
char szCopyr i ght [ MSX_MAXSTRI NG] ;
i nt i NFuncs;
i nt i Ver si on;
} MSXDLLDef ;
Parameters
MSXFuncDef structure
This structure describes the attributes of an external function that will be exported by
the DLL for use by the MetaStock Formula Language. It is used exclusively by
MSXNthFunction function. See MSXNthFunction on page 28 for more details on
using this function.
t ypedef st r uct
{
char szFunct i onName[ MSX_MAXSTRI NG] ;
char szFunct i onDescr i pt i on [ MSX_MAXSTRI NG] ;
i nt i NAr gument s;
} MSXFuncDef ;
Parameters
szCopyright A copyright or other information about this DLL should be copied into this
string. Care must be taken not to write more than MSX_MAXSTRING
characters.
iNFuncs The number of external functions exported by this DLL.
iVersion The MSX version number. This should be set to the constant
MSX_VERSION.
szFunctionName The exported name of the external function. This is the function
name that will be used in the ExtFml() call by the MetaStock
user.
Note: This name must exactly match the spelling and case used in the
EXPORTS or ALIAS section of your code (see example
programs). This is the name used by the GetProcAddress
system call to obtain the address of this function at runtime.
szFunctionDescription The longer description of the external function.
This is displayed in the MetaStock Paste Functions Dialog.
MetaStock
Notes:
MetaStock does not do a partial match on custom strings
All legal variations of a string must be specified
Case is ignored
MSXFuncCustomString structure
This structure defines an allowable string for a custom argument in an external function.
It is used exclusively by the MSXNthCustomString function. See
MSXNthCustomString (page 29) for more details on using this function.
t ypedef st r uct
{
char szSt r i ng[ MSX_MAXSTRI NG] ;
i nt i I D;
} MSXFuncCust omSt r i ng;
Parameters
IMPORTANT: Strings used to define custom arguments must consist only of alphanumeric characters,
e.g., AZ, az, 09. No spaces or special characters are allowed. If illegal characters
are detected in your custom arguments, MetaStock will fail the loading of the DLL and
the external functions that it implements will not be available for use.
szArgName This is the name of the argument displayed by the MetaStock Paste
Functions dialog. This name is also used to identify the argument to the
user when they have a syntax error in their ExtFml() call. For example,
the names of the second and third parameters of the MetaStock built-in
moving average function MOV are PERIODS and METHOD
respectively. If a user left out the second parameter when entering the
ExtFml() function in a Custom Indicator, MetaStock would place the
cursor at the location of the second argument and display a message
similar to: PERIODS expected.
iNCustomStrings The number of custom strings associated with this argument, if it is of
type MSXCustom. For example, if you were defining the third parameter
of the MetaStock built-in moving average function MOV, this entry
would be 14 for: EXPONENTIAL, SIMPLE, TIMESERIES,
TRIANGULAR, WEIGHTED, VARIABLE, VOLUMEADJUSTED, E,
S, T, TRI, W, VAR, and VOL.
szString This is the definition of the string. The case will be ignored when MetaStock
attempts to match a user argument with this string. Names may consist of
alphanumeric characters only (A through Z, a through z, and 0 through 9).
Spaces or other special characters are not allowed.
iI D This is a numeric ID associated with this string. When a call is made to calculate
a function in an MSX DLL, this ID is passed to the calculation function rather
than the string (szString) itself. Each string must have an ID value. If the MSX
DLL defines multiple strings that are synonyms for the same argument (e.g.,
SIMPLE, SIM, S) then the same ID value should be associated with each string.
MetaStock
MSXDataRec structure
The MSXDataRec structure is used by MetaStock to supply security price data to
indicator calculations. All relevant price data for a specific security is contained in this
structure. This structure is automatically supplied to all MSX DLL calculation functions
without the necessity of a specific argument. Please see Programming Guidelines
starting on page 56 for more details about the use of this structure.
The MSXDataRec structure contains a pointer to an array of MSXDateTime structures
(page 35), as well as all the following price MSXDataInfoRec structures: Open, High, Low,
Close, Volume, Open Interest, and Indicator (page 35). It is available to all external
functions in an MSX DLL. The Function Prototype Section on page 27 has more details.
t ypedef st r uct
{
MSXDat eTi me *psDat e;
MSXDat aI nf oRec sOpen;
MSXDat aI nf oRec sHi gh;
MSXDat aI nf oRec sLow;
MSXDat aI nf oRec sCl ose;
MSXDat aI nf oRec sVol ;
MSXDat aI nf oRec sOI ;
MSXDat aI nf oRec sI nd;
char *pszSecur i t yName;
char *pszSymbol ;
char *pszSecur i t yPat h;
char *pszOnl i neSour ce;
i nt i Per i od;
i nt i I nt er val ;
i nt i St ar t Ti me;
i nt i EndTi me;
i nt i Symbol Type;
} MSXDat aRec;
Parameters
psDate Pointer to an array of MSXDateTime structures. See page 35.
sOpen The open price MSXDataInfoRec structure. See page 35.
sHigh The high price MSXDataInfoRec structure. See page 35.
sLow The low price MSXDataInfoRec structure. See page 35.
sClose The close price MSXDataInfoRec structure. See page 35.
sVol The volume MSXDataInfoRec structure. See page 35.
sOI The open interest MSXDataInfoRec structure. See page 35.
sI nd When an external function is used in a custom indicator, the sInd
structure contains the data the custom indicator was dropped on.
If dropped on a high/low/close bar, equivolume, candlevolume, or
candlestick price plot, the structure contains the closing price.
If dropped on another indicator, the values of that indicator are
contained in the structure.
When an external function is used in a System Test or Exploration, this
sInd structure contains data for the selected plot. The selected plot is
the price or indicator that has been selected with the mouse.
When an external function is used in an Expert, this structure contains
data for the plot selected when the expert was initially attached to the
chart. It does not contain the currently selected plot, as is the case with
system tests and explorations. If your MSX DLL requires the sInd
structure to contain valid data in order to return correct values, it is
important that you clearly instruct users of these requirements.
Note: The sInd structure is identical (from the end users perspective) to the
MetaStock Formula Languages P variable discussed in the
MetaStock User's Manual.
MetaStock
arguments for that function, including the argument type. Custom types can be further
expanded to show each possible option.
The following menu options are available:
The Toolbar contains shortcut buttons to the following menu options:
When a function or any of its arguments is highlighted in the display tree, the right side
of the main screen displays all the arguments. You can fill them in as you wish and then
click Call External Function. The function will be called with the specified arguments
and the results will be displayed in a window similar to the following:
The incoming arguments are displayed first under Bold I talics. The result array is
always under Bold regular text, and is always labeled Result. Following the result
array all non-empty input data from the MSXDataRec is displayed. This consists of
Date and Time, and the following MSXDataInfoRec arrays: Open, High, Low, Close,
Vol, Open Interest, and Indicator.
Menu Option Result
File> Setup Display the setup dialog.
File> Load DLLs Load (or re-load) the DLLs from the path defined in the setup
dialog.
File> Stress Test Perform comprehensive stress tests on the selected function.
This option is enabled only when a DLL function is selected.
See Stress Testing Your DLL Functions on page 52 for
more details.
File> Exit Exit the MSXTest application.
View> Toolbar Toggle display of toolbar.
View> Status Bar Toggle display of status bar.
Help> About MSXTest Version information for MSXTest and summary of loaded
DLL copyright strings.
Setup
LoadDLLs
About MSXTest
MetaStock
Considerations for making sure your functions pass the stress test:
Your function should never produce a math exception, such as overflow, underflow,
or division by zero. In practice, your function should not receive values that would
cause overflow or underflow conditions to occur, but because your function may
receive as input the output of another external function you must be prepared to
handle extreme values. The supplied template files, MSXTmplt.cpp, MSXTmplt.pas,
and MSXTmplt.bas, contain a function that forces the passed value to lie within the
minimum and maximum values for a single precision floating point number. If you
perform your floating point calculations using doubles (double precision floating
point), and then force the results into the required range, you can avoid most overflow
and underflow conditions. See the sample DLLs for examples of using this approach.
Test the value of the divisor before any mathematical division to avoid division by
zero exceptions.
Test all arguments for valid ranges. Return MSX_ERROR in the cases where a
clearly defined argument type is out of bounds (such as an out-of-range Custom ID).
Make sure you never access a data array with a negative index.
Be careful about returning the MSX_ERROR result from your external functions.
When MetaStock encounters that return type it will display an extended error
message in a dialog box that will require user response. Report only errors that are
significant problems the user needs to know about not just exceptional situations
your DLL wasnt equipped to handle.
Automating MSXTest From Your IDE
If the compiler IDE you are using supports user-defined tools you may find it useful to
define MSXTest in the tool list. Using the specific IDE tool macros, specify the target
directory of the project as a command line argument for MSXTest. When MSXTest
starts up, it checks its command line arguments for a directory. If one is found, it sets
that directory as the location to search for MSX DLLs.
For example, using Microsoft Visual C++ 6.0, you could define MSXTest as a tool by
selecting Tools> Customize from the main menu. Select the Tools tab, and click
the New icon. Enter MSXTest and press Enter. Fill in the Command field with the
full path to where you installed MSXTest
(e.g. C:\Program Files\Equis\MDK\MSX\MSXTest.exe). Fill in the Arguments
field with $( Tar get Di r ) , and leave the Initial Directory field blank.
Click Close. Now when you select Tools from the main menu, you will see
MSXTest as an entry. Most other compiler IDEs have similar capabilities.
Refer to your IDE documentation for specifics.
MetaStock
Programming Guidelines
This section discusses guidelines, limits and other considerations when creating MSX
external functions. All examples in this section use C syntax. The syntax for Delphi
Pascal and PowerBASIC is similar. See the source listings in the Sample DLL
Programs chapter and included example programs for specific syntax requirements.
Data Storage and Calculations
Data Arrays
All numeric data used within indicator calculations is stored in structures known as
data arrays. Data arrays are used to store price data (e.g., Open, High, Low, etc.),
numeric constants, and the results of an indicator calculation. When MetaStock
supplies security price data and numeric argument data to an MSX DLL function, data
arrays are used. When an MSX DLL calculation function returns the results of an
indicator to MetaStock, the result is returned in a data array.
Data array structures are implemented in the MSXDataInfoRec structure defined on
page 35, and have three basic components:
Data elements.
First valid index.
Last valid index.
The data elements are the actual numeric values associated with the data array. These
values are stored in an array of floating point values. The first valid index and last valid
index are used to define which data elements contain valid data. All data elements
between the first valid index and the last valid index (inclusive) contain valid data. All
elements outside of this range have undefined values and should be ignored for all
calculations.
A data array is considered empty if the first valid index is greater than the last valid
index. Empty data arrays are not uncommon and must be handled properly. Typically,
an empty data array will have a first valid of 0 and a last valid of -1, although any
combination of a first valid greater than a last valid should be considered empty. Empty
data arrays occur when data is not available. For example, an Open Interest data array
used for a security that does not have Open Interest. Likewise, the result of a 100-
period moving average applied to a security price data array that contains only 90 data
elements would be an empty data array.
First and last valid indexes are very important during indicator calculations.
Calculations should always be restricted to data elements contained within the first
valid/last valid range. Care must be taken to make sure that a data array produced from
the result of a calculation has the correct first valid/last valid settings.
Two important concepts must be understood to correctly set the first valid and last valid
indexes for the returned data array:
Always restrict calculations to the union of the valid data ranges of all input data
arrays used.
The first valid and last valid values of a calculation result must maintain their position
relative to the values of all input data arrays.
The following example will help to illustrate these concepts.
Assume that an MSX DLL implements a function that adds three data arrays together
and then calculates a three period moving average of the sum. The following statistics
apply to the three data arrays supplied as input to the function:
Dat a Ar r ay 1: Fi r st Val i d = 1, Last Val i d = 10
Dat a Ar r ay 2: Fi r st Val i d = 3, Last Val i d = 10
Dat a Ar r ay 3: Fi r st Val i d = 1, Last Val i d = 7
MetaStock
it is applied. Since the input array had a first valid of 3, the 3-period moving average
did not come up to speed until the fifth data element. Again, the last valid value is set
to 7 because the input data array had a last valid of 7.
Security Price Data
When MetaStock calls a calculation function in an MSX DLL, it automatically gives the
DLL access to security price data. The DLL does not have to explicitly declare an
argument in the external function for access to the security data. This means that even if
an external function has no arguments, the calculation functions in the DLL will still be
given security price and detail data to work with.
MSX DLL calculation
function
An MSX DLL calculation function has no way of knowing which type of formula
(e.g., Custom Indicator, System Test, etc.) is calling the external function. The external
function calculation process only knows that it is given a set of data arrays that define
the price data for the target security. The external calculation function simply performs
the appropriate calculations and returns the resulting data array to MetaStock.
MSXDataRec structure MetaStock uses the MSXDataRec structure (page 36) to supply security price and
detail data to an MSX DLL.
In the case of an external function used in an Indicator, the MSXDataRec structure
will contain the price and detail data for the base security of the chart where the custom
indicator is being calculated.
For System Tests, the structure is loaded with base security data for the active
chart when the system test was launched.
For Explorations, the structure is loaded with security data for the security
currently being explored.
For Experts, the structure is loaded with the base security data for the chart
where the expert is attached.
The MSXDataRec structure contains seven data arrays stored in MSXDataInfoRec
structures (page 35). These data arrays store all relevant price data for the security.
Some of these arrays may be empty (see the discussion of empty data arrays in the
MSXDataInfoRec section (page 35) if the security does not have data for that price field.
Also contained in the MSXDataRec structure is a pointer to an array of MSXDateTime
structures. This array contains date and time information for each data point. If a
calculation function needs to access the date and time for the Nth bar of the security,
it would reference the Nth element of the psDate array. Note that this is not a data
array like the sHigh, sLow, etc.
sInd data array The data array sInd contains data for a user-selected indicator. In the case of a Custom
Indicator this data array will contain the value for the chart object on which the indicator
was dropped. For System Tests and Explorations, this array contains the selected plot
(if there is one) of the active chart when the system Test or Exploration was started. For
Experts, this array contains the selected plot (if there is one) of the chart when the
Expert was attached. In all cases, if no plot is selected the sInd data array will be empty.
Notice that the location of the data in these arrays is synchronized. The Nth element
of each array corresponds to the same time frame.
sClose data array The sClose data array always contains the maximum data points. All other data
arrays will contain equal to or less than the value of sClose.iLastValid.
iFirstValid, iLastValid
settings
The iFirstValid and iLastValid settings in the sClose data array are significant.
Typically the number of data elements in this data array defines the maximum
number of data elements stored in the other price arrays. This is important for
determining the number of valid elements contained in the psDate array. For
example, if the sClose.iFirstValid field contains 100 and the sClose.iLastValid field
contains 200, you can be certain that the psDate array contains valid data at
psDate[100] through psDate[200].
Note: After a calculation is performed, the a_psResultRec->psResultArrays iLastValid should
never be greater than the iLastValid value of the sClose data array.
MetaStock
MSX Index
A
Argument range tests 53
B
Borland C++ 5.0
Creating an MSX DLL 43
Debugging an MSX DLL 46
Borland C++ Builder 4.0
Creating an MSX DLL 41
Debugging an MSX DLL 46
Borland Delphi Pascal
Creating an MSX DLL 43
Debugging an MSX DLL 46
C
C
Creating an MSX DLL 40, 41, 43
Debugging an MSX DLL 45, 46
Calculation Functions 30
Calculation Structures 35
MSXDataInfoRec 35
MSXDataRec 36
MSXDateTime 35
custom strings, and partial matches 34
D
Data
Data Array 56
Price Data 58
Sample 48
Types 31
data array
Argument range 53
tests
Max/Min 52
Special Case 52
Data Types 31
Dates 31
Strings 31
Times 31
distributing your MSX DLL 60
E
ExtFml 26, 32, 34
F
Function Argument Structures 38
MSXCustomArgsArray 39
MSXDataInfoRecArgsArray 38
MSXNumericArgsArray 39
MSXResultRec 39
MSXStringArgsArray 39
H
Help 26
I
iFirstValid 30, 35
defined 35
iFirstValid setting 58
iLastValid 30, 35
defined 35
iLastValid setting 58
iLastValue indexes 30
Initialization Functions 27
MSXInfo 27
MSXNthArg 28
MSXNthCustomString 29
MSXNthFunction 28
Initialization Structures 32
MSXDLLDef 32
MSXFuncArgDef 33
MSXFuncCustomString 34
MSXFuncDef 32
L
lTime 35
M
Max/Min data array tests 52
MetaStock External Function (MSX) defined 25
Microsoft Visual C++
Creating an MSX DLL 40
Debugging an MSX DLL 45
MSFL, using in an MSX DLL 60
MSX DLL, distributing 60
MSX_ERROR 39
MSX_MAXARGS 33, 38
MSX_MAXSTRING 32
MSX_MAXSTRING, defined 31
MSX_VERSION 32
MSXCustom 34
MSXCustomArgsArray structure 39
MSXDataInfoRec 36
MSXDataInfoRec structure 35
MSXDataInfoRecArgsArray structure 38
MSXDataRec 35
MSXDataRec structure 58
described 36
MSXDateTime 35, 36
MSXDLLDef structure 27
MSXFuncArgDef data structure 29
MSXFuncCustomString data structure 29
MSXFuncDef data structure 28
62 MetaStock External Functions (MSX) MetaStock
MSXNthCustomString 34
MSXNumeric arguments 38
MSXNumericArgsArray argument array 38
MSXNumericArgsArray structure 39
MSXResultRec structure 39
MSXStringArgsArray structure 39
MSXStruc.bas 32
MSXStruc.pas 32
P
partial match on custom strings 34
PowerBASIC
Creating an MSX DLL 44
Debugging an MSX DLL 47
Programming Considerations
UI Restrictions 59
S
sClose data array 58
sInd structure 36
Special Case data array tests 52
strings, and partial matches 34
T
Tech Notes
Using MSFL in an MSX DLL 60
Technical support 26
Testing
MSXTest 48
Stress Testing 52
Testing your DLL with MetaStock 55
V
Variable Notation 31
Visual Basic 25
W
Win32 43
Win32 DLL 25
MetaStock
case 0:
a_psFuncAr gDef - >i Ar gType = MSXDat aAr r ay; / / dat a ar r ay
st r cpy ( a_psFuncAr gDef - >szAr gName, "Dat aAr r ay") ;
br eak;
case 1:
a_psFuncAr gDef - >i Ar gType = MSXNumer i c; / / Numer i c
st r cpy ( a_psFuncAr gDef - >szAr gName, "Per i od") ;
br eak;
case 2:
a_psFuncAr gDef - >i Ar gType = MSXCust om; / / Cust omType
a_psFuncAr gDef - >i NCust omSt r i ngs = 4;
st r cpy ( a_psFuncAr gDef - >szAr gName, "Met hod") ;
br eak;
def aul t :
l _bRt r n = MSX_ERROR;
br eak;
}
br eak;
def aul t :
l _bRt r n = MSX_ERROR;
br eak;
}
r et ur n l _bRt r n;
}
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL __st dcal l MSXNt hCust omSt r i ng ( i nt a_i Nt hFunc, i nt a_i Nt hAr g,
i nt a_i Nt hSt r i ng,
MSXFuncCust omSt r i ng *a_psCust omSt r i ng)
{
BOOL l _bRt r n = MSX_SUCCESS;
t ypedef st r uct
{
char *szSt r i ng;
i nt i I D;
} Local St r i ngEl ement ;
Local St r i ngEl ement l _sTheSt r i ngs[ ] =
{
{"Si mpl e", 0}, {"S", 0},
{"Wei ght ed", 1}, {"W", 1}
};
swi t ch ( a_i Nt hFunc)
{
case 0:
swi t ch ( a_i Nt hAr g)
{
case 2:
i f ( a_i Nt hSt r i ng >= 0 && a_i Nt hSt r i ng < NMyMovCust St r i ngs)
{
st r ncpy ( a_psCust omSt r i ng- >szSt r i ng,
l _sTheSt r i ngs[ a_i Nt hSt r i ng] . szSt r i ng,
MSX_MAXSTRI NG- 1) ;
a_psCust omSt r i ng- >i I D = l _sTheSt r i ngs[ a_i Nt hSt r i ng] . i I D;
}
br eak;
def aul t :
l _bRt r n = MSX_ERROR;
br eak;
}
br eak;
def aul t :
l _bRt r n = MSX_ERROR;
br eak;
}
r et ur n l _bRt r n;
}
/ / ***********************************************************************
/ / Thi s l ocal ut i l i t y f unct i on i s used t o hel p ensur e t hat no over f l ows
/ / or under f l ows wi l l occur dur i ng cal cul at i ons. The MSXTest pr ogr am
/ / St r ess Test f unct i on wi l l cal l your DLL wi t h a wi de r ange of val ues,
/ / i ncl udi ng posi t i ve and negat i ve val ues of FLT_MAX and FLT_MI N.
/ / Per f or mal l i nt er medi at e cal cul at i ons usi ng doubl es and t hen f or ce t he
MetaStock
Visual Basic
The following points should be observed to create a Visual Basic application that uses
the MSFL DLL.
1. Add the msfl.bas module to the project, it can be found in the msfl/include
folder. The msfl.bas module contains the MSFL function and type declares.
2. Take care when using DLL procedures.
Microsoft Visual Basic cannot verify that you are passing correct values to the
MSFL DLL procedures. If you pass incorrect values, the procedure may fail, which
may cause your application to shut down. This doesn't cause permanent harm to
your application, but may cause data corruption and require the user to reload and
restart the application.
3. Be sure to check the return values of MSFL functions to test for errors or messages.
A convenient error testing function is provided in the msflutil.bas module, which
also resides in the msfl/include folder.
4. Special attention must be taken when dealing with string data.
Like the Windows API, the MSFL uses null-terminated strings. These strings differ
from those used in Visual Basic. In addition, variable- and fixed-length strings differ in
Visual Basic; for example, comparing a fixed-length string containing ABC may not
equal a variable-length string containing the exact same text.
The msflutil.bas module, which resides in the msfl/include folder, provides
two convenient string conversion functions.
NullTerminate(strNullMe As String) As String
NullTerminate null-terminates a variable or fixed length string.
All fixed-length strings must be null-terminated before calling any of the
MSFL functions.
Extract(strFixed As String, strJunk As String) As String
Extract returns a variable-length string containing the legitimate portion of a
string. Pass a string to the strJunk parameter which contains the illegitimate
character, typically either a space or null (i.e. Chr ( 0) ). Extract should be used
on all strings returned from the MSFL.
Delphi
The following steps must be taken to create a Delphi form that uses the MSFL DLL.
1. Add the msfl.pas unit to the project; it can be found in the msfl/include folder.
The msfl.pas unit contains the MSFL constant, record and function declarations.
2. Add the MSFL unit to the forms uses clause.
PowerBASIC
The following points should be observed to create a PowerBASIC application that uses
the MSFL DLL.
1. Ensure that the msfl.inc module is included in any file of your project that makes
MSFL calls. The msfl.inc module can be found in the msfl/include folder.
The msfl.inc module contains the MSFL function and type declares.
2. Be sure to check the return values of MSFL functions to test for errors or messages.
A convenient error testing function is provided in the msfl.inc module.
MetaStock
Composites
Composites are simulated securities composed of two securities. The price data is
calculated from the two securities that make up the composite. The first security of the
composite is known as the primary security, and the second is known as the
secondary security. Price data can only be calculated for the common records
between the primary and secondary securities.
Except for a few restrictions, the application program can use composite securities like
standard securities. The MSFL manages the matching and calculation of the simulated
price data.
Because composites price records are calculated rather than being stored on disk, there
are no record numbers associated with composite price records. Any functions that
require a record number cannot be used with composite securities. In addition, any
functions that return record numbers will always return a zero for a composites record
number.
If the application attempts to call a function that cannot be used with composite securities,
the MSFL function will return an MSFL_ERR_SECURITY_IS_A_COMPOSITE error.
Multi-user Support
To provide multi-user support, the MSFL implements two types of locking, directory
and security. Directory locking is internal to the MSFL. Security locking is initiated by
the application program via MSFL function calls.
Directory
When the MSFL requires exclusive access to one or more of the files in a directory, the
directory is often locked, restricting access to other users. In most cases, the MSFL
internal retry period will shield the application from noticing this situation. However, if
the directory remains locked, an MSFL_ERR_DIR_IS_BUSY error is returned.
Security
Security locking allows the application to gain access to securities and their price data.
Multiple users are permitted to prevent write (read) lock a security, but only one user
is permitted to write or full lock a security at any given time.
Because of the multi-processing nature of Microsoft Windows, even single-user
applications should guard against multiple applications and/or users accessing the same
data. Thus, the MSFL requires even single-user applications to lock and unlock securities.
For detailed information on locking securities, see the Security Locking section in
Using The Library (page 86).
MetaStock
Listed By Type
Here are type-ordered lists of the MSFL functions (each linked to their description page).
Data.
Date / Time.
Directory.
Error Reporting.
Locking.
Function Name Page
MSFL1_GetDataRecordCount 97
MSFL1_GetRecordCountForDateRange 110
MSFL1_ReadDataRec 122
MSFL2_ReadBackMultipleRecs 126
MSFL2_ReadDataRec 127
MSFL2_ReadMultipleRecs 128
MSFL2_ReadMultipleRecsByDates 129
Function Name Page
MSFL1_FormatDate 94
MSFL1_FormatTime 95
MSFL1_GetDayMonthYear 98
MSFL1_GetHourMinTicks 104
MSFL1_MakeMSFLDate 117
MSFL1_MakeMSFLTime 118
MSFL1_ParseDateString 120
MSFL1_ParseTimeString 121
Function Name Page
MSFL1_CloseDirectory 92
MSFL1_GetDataPath 97
MSFL1_GetDirectoryNumber 99
MSFL1_GetDirNumberFromHandle 100
MSFL1_GetDirectoryStatus 100
MSFL1_OpenDirectory 119
Function Name Page
MSFL1_GetErrorMessage 102
MSFL1_GetLastFailedLockInfo 105
MSFL1_GetLastFailedOpenDirInfo 106
Function Name Page
MSFL1_GetSecurityLockedStatus 114
MSFL1_LockSecurity 116
MSFL1_UnlockSecurity 124
MetaStock
MSFL1_CloseDirectory
C
i nt MSFL1_Cl oseDi r ect or y( char cDi r Number )
Visual Basic
MSFL1_Cl oseDi r ect or y ( ByVal cDi r Number As Byt e) As Long
Delphi
MSFL1_Cl oseDi r ect or y ( cDi r Number : char ) : i nt eger ;
PowerBASIC
MSFL1_Cl oseDi r ect or y ( BYVAL cDi r Number AS BYTE) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_DIR_NOT_OPEN if the directory is not open
Parameters
Remarks
Closes an open directory. All open files in the directory are closed.
When the last user closes a directory, the MASTER, EMASTER, and XMASTER
files are updated with any changes made while the directory was open and the
temporary MSFL files are removed from the directory.
See Also
MSFL1_OpenDirectory (page 119)
MSFL1_Shutdown (page 124)
MSFL1_FindDataDate
C
i nt MSFL1_Fi ndDat aDat e( HSECURI TY hSecur i t y,
Dat eTi me_st r uct *psRecor dDat e,
WORD *pwRecor dNum,
i nt i Fi ndMode)
Visual Basic
MSFL1_Fi ndDat aDat e( ByVal hSecur i t y As Long,
psRecor dDat e As Dat eTi me_st r uct ,
pwRecor dNumAs I nt eger ,
ByVal i Fi ndMode As Long) As Long
Delphi
MSFL1_Fi ndDat aDat e( hSecur i t y : HSECURI TY;
Var psRecor dDat e : Dat eTi me_st r uct ;
Var pwRecor dNum: wor d;
i Fi ndMode : i nt eger ) : i nt eger ;
PowerBASIC
MSFL1_Fi ndDat aDat e( BYVAL hSecur i t y AS DWORD,
psRecor dDat e AS Dat eTi me_st r uct ,
pwRecor dNumAs Wor d,
BYVAL i Fi ndMode As Long) As Long
Locking
Prevent Write Lock
ID Description
cDirNumber Identifies the directory in which to close.
MetaStock
PowerBASIC
MSFL1_Fi ndDat aRec( BYVAL hSecur i t y AS DWORD,
BYVAL wRecor dNumAs Wor d,
psRecor dDat e AS Dat eTi me_st r uct ) As Long
Locking
Prevent Write Lock
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_RECORD_OUT_OF_RANGE if a price record does not exist for the
specified record number
MSFL_ERR_SECURITY_HAS_NO_DATA if the security has no price records
Parameters
Remarks
Finds the price record for the specified record number and sets the current data
position to that record.
Note: This function cannot be used with composite securities.
See Also
MSFL1_FindDataDate (page 92)
MSFL1_GetCurrentDataPos (page 96)
MSFL1_SeekBeginData (page 123)
MSFL1_SeekEndData (page 123)
MSFL1_FormatDate
C
i nt MSFL1_For mat Dat e( LPSTR pszDat eSt r i ng,
WORD wSt r i ngSi ze,
l ong l Dat e) ;
Visual Basic
MSFL1_For mat Dat e( ByVal pszDat eSt r i ng As St r i ng,
ByVal wSt r i ngSi ze As I nt eger ,
ByVal l Dat e As Long) As Long
Delphi
MSFL1_For mat Dat e( pszDat eSt r i ng : LPSTR;
wSt r i ngSi ze : wor d;
l Dat e : i nt eger ) : i nt eger ;
PowerBASIC
MSFL1_For mat Dat e( pszDat eSt r i ng AS ASCI I Z,
BYVAL wSt r i ngSi ze As Wor d,
BYVAL l Dat e As Long) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_DATE if the date to be formatted is invalid
ERROR_INSUFFICIENT_BUFFER if the date string is not large enough
ID Description
hSecurity Identifies the security.
wRecordNum Specifies the record number to find. Record numbers are one based.
psRecordDate Points to a DateTime_struct structure that receives the date/time of price
record found.
MetaStock
Remarks
Formats an MSFL time as a time string. The string is formatted based on the
Windows time format, using the default system locale.
See Also
MSFL1_FormatDate (page 94)
MSFL1_GetHourMinTicks (page 104)
MSFL1_ParseDateString (page 120)
MSFL1_ParseTimeString (page 121)
MSFL1_GetCurrentDataPos
C
i nt MSFL1_Get Cur r ent Dat aPos( HSECURI TY hSecur i t y,
WORD *pwRecor dNum,
Dat eTi me_st r uct *psRecor dDat e)
Visual Basic
MSFL1_Get Cur r ent Dat aPos( ByVal hSecur i t y As Long,
pwRecor dNumAs I nt eger ,
psRecor dDat e As Dat eTi me_st r uct ) As Long
Delphi
MSFL1_Get Cur r ent Dat aPos( hSecur i t y : HSECURI TY;
Var pwRecor dNum: wor d;
Var psRecor dDat e : Dat eTi me_st r uct ) : i nt eger ;
PowerBASIC
MSFL1_Get Cur r ent Dat aPos( BYVAL hSecur i t y AS DWORD,
pwRecor dNumAs Wor d,
psRecor dDat e AS Dat eTi me_st r uct ) As Long
Locking
Prevent Write Lock
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_LOCKED if the security is not locked
Parameters
Remarks
Gets the record number and the date/time of the price record at the current data
position. If the security is a composite the record number is returned as zero.
See Also
MSFL1_FindDataDate (page 92)
MSFL1_FindDataRec (page 93)
MSFL1_SeekBeginData (page 123)
MSFL1_SeekEndData (page 123)
ID Description
hSecurity Identifies the security.
pwRecordNum Points to a WORD that receives the record number of the current data
position. If the record is a composite the record number is returned as
zero.
psRecordDate Points to a DateTime_struct structure (page 81) that receives the
date/time of price record at the current data position.
MetaStock
PowerBASIC
MSFL1_Get Dat aRecor dCount ( BYVAL hSecur i t y AS DWORD,
pwNumOf Dat aRecs As Wor d) As Long
Locking
Prevent Write Lock
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_LOCKED if the security is not locked
Parameters
Remarks
Gets the number of price records for the specified security.
For composite securities, the number of price records returned is an estimate. The
actual number of records will be equal to or less than what is reported by this
function.
See Also
MSFL1_GetRecordCountForDateRange (page 110)
MSFL1_GetDayMonthYear
C
i nt MSFL1_Get DayMont hYear ( WORD *pwDay,
WORD *pwMont h,
WORD *pwYear ,
l ong l Dat e) ;
Visual Basic
MSFL1_Get DayMont hYear ( pwDay As I nt eger ,
pwMont h As I nt eger ,
pwYear As I nt eger ,
ByVal l Dat e As Long) As Long
Delphi
MSFL1_Get DayMont hYear ( Var pwDay : wor d;
Var pwMont h : wor d;
Var pwYear : wor d
l Dat e: l ongi nt ) : i nt eger ;
PowerBASIC
MSFL1_Get DayMont hYear ( pwDay As Wor d,
pwMont h As Wor d,
pwYear As Wor d,
BYVAL l Dat e As Long) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_DATE if the date is invalid
Parameters
ID Description
hSecurity Identifies the security.
pwNumOfDataRecs Points to a WORD that receives the number of price records.
ID Description
pwDay Points to a WORD that receives the day of the month.
pwMonth Points to a WORD that receives the month; January = 1, February = 2,
and so on.
MetaStock
MSFL1_GetDirNumberFromHandle
C
i nt MSFL1_Get Di r Number Fr omHandl e( HSECURI TY hSecur i t y,
char *pcDi r Number )
Visual Basic
MSFL1_Get Di r Number Fr omHandl e( ByVal hSecur i t y As Long,
pcDi r Number As Byt e) As Long
Delphi
MSFL1_Get Di r Number Fr omHandl e( hSecur i t y : HSECURI TY;
Var pcDi r Number : char ) : i nt eger ;
PowerBASIC
MSFL1_Get Di r Number Fr omHandl e( BYVAL hSecur i t y AS DWORD,
pcDi r Number AS BYTE) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_SECURITY_HANDLE if the handle is invalid
Parameters
Remarks
Gets the directory number for the specified security.
See Also
MSFL1_GetSecurityHandle (page 111)
MSFL1_GetDirectoryNumber (page 99)
MSFL1_GetDirectoryStatus
C
i nt MSFL1_Get Di r ect or ySt at us( char cDi r Number ,
LPCSTR pszDi r ect or y,
MSFLDi r ect or ySt at us_st r uct *psDi r St at us)
Visual Basic
MSFL1_Get Di r ect or ySt at us( ByVal cDi r Number As Byt e,
ByVal pszDi r ect or y As St r i ng,
psDi r St at us As MSFLDi r ect or ySt at us_st r uct ) As Long
Delphi
MSFL1_Get Di r ect or ySt at us( cDi r Number : char ;
pszDi r ect or y : LPCSTR;
Var psDi r St at us : MSFLDi r ect or ySt at us_st r uct ) : i nt eger ;
PowerBASIC
MSFL1_Get Di r ect or ySt at us( BYVAL cDi r Number AS BYTE,
pszDi r ect or y AS ASCI I Z,
psDi r St at us AS MSFLDi r ect or ySt at us_st r uct ) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_DIR_NOT_OPEN if the directory is not open
MSFL_ERR_DIR_DOES_NOT_EXIST if the directory does not exist
ID Description
hSecurity Identifies the security.
pcDirNumber Points to a character that receives the directory number for the security.
MetaStock
See Also
MSFL1_GetDataPath (page 97),
MSFL1_GetDirectoryNumber (page 99),
MSFL1_GetSecurityCount (page 111)
MSFL1_OpenDirectory (page 119)
MSFL1_GetErrorMessage
C
LPSTR MSFL1_Get Er r or Message( i nt i Er r ,
LPSTR pszEr r or Message,
WORD wMaxMsgLengt h)
Visual Basic
MSFL1_Get Er r or Message( ByVal i Er r As Long,
ByVal pszEr r or Message As St r i ng,
ByVal wMaxMsgLengt h As I nt eger ) As St r i ng
Delphi
MSFL1_Get Er r or Message( i Er r : i nt eger ;
pszEr r or Message : LPSTR;
wMaxMsgLengt h : WORD ) : LPSTR;
PowerBASIC
MSFL1_Get Er r or Message( BYVAL i Er r As Long,
pszEr r or Message AS ASCI I Z,
BYVAL wMaxMsgLengt h As Wor d) AS STRI NG
Locking
None
wDriveType The drive type, which can be any one of the following:
MSFL_DRIVE_TYPE_UNKNOWN
The drive type is unknown.
MSFL_DRIVE_TYPE_REMOVABLE
The drive is removable media.
MSFL_DRIVE_TYPE_FIXED
The drive is fixed (i.e. a hard drive).
MSFL_DRIVE_TYPE_REMOTE
The drive is remote (i.e. a network drive).
MSFL_DRIVE_TYPE_CD_ROM
The drive is a local CD-ROM drive network CD-ROM drives are
reported as remote drives.
MSFL_DRIVE_TYPE_RAM_DISK
The drive is a RAM disk.
bOpen Boolean value indicating if the directory is open.
bReadOnly Boolean value indicating if the directory is on read-only media. This
field is only defined if the directory is open.
bUserI nvalid Boolean value indicating if the user is invalid. A user is invalid when
another user with the same user ID is forced into the directory already
in use by the current user. This field is only defined if the directory is
open.
cDirNumber The directory number, if the directory is open.
dwNumOfSecurities The number of securities in the directory, if the directory is open.
Remember if the directory is not open, bReadOnly, bUserInvalid,
cDirNumber, and dwNumOfSecurities are undefined. In other
words, the directory must be open to determine if the directory is
read-only.
ID Description
MetaStock
See Also
MSFL1_GetLastSecurityInfo (page 106)
MSFL1_GetNextSecurityInfo (page 108)
MSFL1_GetPrevSecurityInfo (page 109)
MSFL1_GetSecurityInfo (page 113)
MSFL2_GetSecurityHandles (page 125)
MSFL1_GetHourMinTicks
C
i nt MSFL1_Get Hour Mi nTi cks( WORD *pwHour ,
WORD *pwMi n,
WORD *pwTi cks,
l ong l Ti me) ;
Visual Basic
MSFL1_Get Hour Mi nTi cks( pwHour As I nt eger ,
pwMi n As I nt eger ,
pwTi cks As I nt eger ,
ByVal l Ti me As Long) As Long
Delphi
MSFL1_Get Hour Mi nTi cks( Var pwHour : wor d;
Var pwMi n : wor d;
Var pwTi cks : wor d;
l Ti me : l ongi nt ) : i nt eger ;
PowerBASIC
MSFL1_Get Hour Mi nTi cks( pwHour As Wor d,
pwMi n As Wor d,
pwTi cks As Wor d,
BYVAL l Ti me As Long) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_TIME if the time is invalid
Parameters
Remarks
Extracts an MSFL time into its components: hour, minutes and ticks.
See Also
MSFL1_FormatTime (page 95)
MSFL1_GetDayMonthYear (page 98)
MSFL1_MakeMSFLTime (page 118)
ID Description
pwHour Points to a WORD that receives the hour. The hour is always in 24-hour
format.
pwMin Points to a WORD that receives the minutes.
pwTicks Points to a WORD that receives the ticks.
lTime The MSFL time to be extracted.
MetaStock
MSFL1_GetLastFailedOpenDirInfo
C
i nt MSFL1_Get Last Fai l edOpenDi r I nf o( LPSTR pszAppName,
LPSTR pszUser Name)
Visual Basic
MSFL1_Get Last Fai l edOpenDi r I nf o( ByVal pszAppName As St r i ng,
ByVal pszUser Name As St r i ng) As Long
Delphi
MSFL1_Get Last Fai l edOpenDi r I nf o( pszAppName : LPSTR;
pszUser Name : LPSTR) : i nt eger ;
PowerBASIC
MSFL1_Get Last Fai l edOpenDi r I nf o( pszAppName AS ASCI I Z,
pszUser Name AS ASCI I Z) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
Parameters
Remarks
Gets the user information for the last failed directory open. If the directory is in use by
a non-MSFL application or if the user is already using the directory, this function can
be used to retrieve the user information and display a message for the user.
Note: This function will only return the user information if MSFL1_OpenDirectory (page 119)
fails with an MSFL_ERR_USER_ID_ALREADY_IN_DIR or an
MSFL_ERR_NON_MSFL_USER_IN_DIR error.
See Also
MSFL1_OpenDirectory (page 119)
MSFL1_GetErrorMessage (page 102)
MSFL1_GetLastSecurityInfo
C
i nt MSFL1_Get Last Secur i t yI nf o( char cDi r Number ,
MSFLSecur i t yI nf o_st r uct *psSecur i t yI nf o)
Visual Basic
MSFL1_Get Last Secur i t yI nf o( ByVal cDi r Number As Byt e,
psSecur i t yI nf o As MSFLSecur i t yI nf o_st r uct ) As Long
Delphi
MSFL1_Get Last Secur i t yI nf o( cDi r Number : char ;
Var psSecur i t yI nf o : MSFLSecur i t yI nf o_st r uct ) : i nt eger ;
PowerBASIC
MSFL1_Get Last Secur i t yI nf o( BYVAL cDi r Number AS BYTE,
psSecur i t yI nf o AS MSFLSecur i t yI nf o_st r uct ) As Long
ID Description
pszAppName Points to a null-terminated string that receives the application name.
The application name can be up to
MSFL_MAX_APP_NAME_LENGTH bytes, not including the
terminating null.
pszUserName Points to a null-terminated string that receives the user name.
The user name can be up to MSFL_MAX_USER_NAME_LENGTH
bytes, not including the terminating null. If a non-MSFL application is
using the directory, the user name is returned blank.
MetaStock
See Also
MSFL1_Initialize (page 115)
MSFL1_Shutdown (page 124)
MSFL1_GetNextSecurityInfo
C
i nt MSFL1_Get Next Secur i t yI nf o( HSECURI TY hSecur i t y,
MSFLSecur i t yI nf o_st r uct *psSecur i t yI nf o)
Visual Basic
MSFL1_Get Next Secur i t yI nf o( ByVal hSecur i t y As Long,
psSecur i t yI nf o As MSFLSecur i t yI nf o_st r uct ) As Long
Delphi
MSFL1_Get Next Secur i t yI nf o( hSecur i t y : HSECURI TY;
Var psSecur i t yI nf o : MSFLSecur i t yI nf o_st r uct ) : i nt eger ;
PowerBASIC
MSFL1_Get Next Secur i t yI nf o( BYVAL hSecur i t y AS DWORD,
psSecur i t yI nf o AS MSFLSecur i t yI nf o_st r uct ) As Long
Locking
None
Return Values
MSFL_MSG_LAST_SECURITY_IN_DIR if successful and this security is the last
security in the directory
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_FOUND if there are no more securities in the
directory
Parameters
Remarks
Gets the security information for the next security in the directory.
Note: If the security is not locked when calling this function, the security information returned may
not reflect changes made by another user. In addition, the starting and ending dates and times
for composite securities may not reflect changes made to the primary or secondary securities.
See Also
MSFL1_GetFirstSecurityInfo (page 103)
MSFL1_GetLastSecurityInfo (page 106)
MSFL1_GetPrevSecurityInfo (page 109)
MSFL1_GetSecurityCount (page 111)
MSFL1_GetSecurityInfo (page 113)
MSFL2_GetSecurityHandles (page 125)
ID Description
hSecurity Identifies the security. If the handle is zero, the current directory and
position from the last call to any one of the MSFL1_GetxxxxSecurityInfo
functions is used. This allows the application to step through the list of
securities by repeated calls to this function.
psSecurityI nfo Points to an MSFLSecurityInfo_struct structure (page 82) that receives
the security information. The dwTotalSize member must be set to the
structure size before calling MSFL1_GetNextSecurityInfo.
MetaStock
MSFL1_GetRecordCountForDateRange
C
i nt MSFL1_Get Recor dCount For Dat eRange( HSECURI TY hSecur i t y,
const Dat eTi me_st r uct *psFi r st Dat e,
const Dat eTi me_st r uct *psLast Dat e,
WORD *pwNumOf Dat aRecs)
Visual Basic
MSFL1_Get Recor dCount For Dat eRange( ByVal hSecur i t y As Long,
psFi r st Dat e As Dat eTi me_st r uct ,
psLast Dat e As Dat eTi me_st r uct ,
pwNumOf Dat aRecs As I nt eger ) As Long
Delphi
MSFL1_Get Recor dCount For Dat eRange( hSecur i t y : HSECURI TY;
const psFi r st Dat e : Dat eTi me_st r uct ;
const psLast Dat e : Dat eTi me_st r uct ;
Var pwNumOf Dat aRecs : wor d) : i nt eger ;
PowerBASIC
MSFL1_Get Recor dCount For Dat eRange( BYVAL hSecur i t y AS DWORD,
psFi r st Dat e AS Dat eTi me_st r uct ,
psLast Dat e AS Dat eTi me_st r uct ,
pwNumOf Dat aRecs As Wor d) As Long
Locking
Prevent Write Lock
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_HAS_NO_DATA if the security has no price records
Parameters
Remarks
Gets the number of price records within a date range.
For composite securities, the number of price records returned is an estimate. The
actual number of records will be equal to or less than what is reported by this
function.
See Also
MSFL1_GetDataRecordCount (page 97)
ID Description
hSecurity Identifies the security.
psFirstDate Points to a DateTime_struct structure (page 81) that specifies the
date/time of the first record in the date range.
psLastDate Points to a DateTime_struct structure (page 81) that specifies the
date/time of the last record in the date range.
pwNumOfDataRecs Points to a WORD that receives the number of price records within
the specified date range.
MetaStock
Parameters
Remarks
Gets the security handle for the specified security.
See Also
MSFL1_GetSecurityID (page 112)
MSFL2_GetSecurityHandles (page 125)
MSFL1_GetSecurityID
C
i nt MSFL1_Get Secur i t yI D( HSECURI TY hSecur i t y,
MSFLSecur i t yI dent i f i er _st r uct *psSecur i t yI D)
Visual Basic
MSFL1_Get Secur i t yI D( ByVal hSecur i t y As Long,
psSecur i t yI D As MSFLSecur i t yI dent i f i er _st r uct ) As Long
Delphi
MSFL1_Get Secur i t yI D( hSecur i t y : HSECURI TY;
Var psSecur i t yI D : MSFLSecur i t yI dent i f i er _st r uct ) :
i nt eger ;
PowerBASIC
MSFL1_Get Secur i t yI D( BYVAL hSecur i t y AS DWORD,
psSecur i t yI D AS MSFLSecur i t yI dent i f i er _st r uct ) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_FOUND if the security has been deleted or if the
handle is invalid
Parameters
Remarks
Gets the security identifier for the specified security.
The MSFLSecurityIdentifier_struct structure is defined as follows.
t ypedef st r uct
{
DWORD dwTot al Si ze;
char cDi r Number ;
char szSymbol [ MSFL_MAX_SYMBOL_LENGTH+1] ;
char cPer i odi ci t y;
WORD wI nt er val ;
BOOL bComposi t e;
char szCompSymbol [ MSFL_MAX_SYMBOL_LENGTH+1] ;
char cCompOper at or ;
} MSFLSecur i t yI dent i f i er _st r uct ;
ID Description
psSecurityI D Points to an MSFLSecurityIdentifier_struct structure that specifies the
security. The dwTotalSize member must be set to the structure size before
calling MSFL1_GetSecurityHandle.
phSecurity Points to an HSECURITY that receives the security handle for the
specified security.
ID Description
hSecurity Identifies the security.
psSecurityID Points to an MSFLSecurityIdentifier_struct structure (page 112) that
receives the security identifier. The dwTotalSize member must be set to
the structure size before calling MSFL1_GetSecurityID.
MetaStock
Parameters
Remarks
Gets the security information for the specified security.
Note: If the security is not locked when calling this function, the security information returned may
not reflect changes made by another user. In addition, the starting and ending dates for
composite securities may not reflect changes made to the primary or secondary securities.
See Also
MSFL1_GetFirstSecurityInfo (page 103)
MSFL1_GetLastSecurityInfo (page 106)
MSFL1_GetNextSecurityInfo (page 108)
MSFL1_GetPrevSecurityInfo (page 109)
MSFL2_GetSecurityHandles (page 125)
MSFL1_GetSecurityLockedStatus
C
i nt MSFL1_Get Secur i t yLockedSt at us( HSECURI TY hSecur i t y,
i nt *pi LockSt at us,
UI NT *pui LockType)
Visual Basic
MSFL1_Get Secur i t yLockedSt at us( ByVal hSecur i t y As Long,
pi LockSt at us As Long,
pui LockType As Long) As Long
Delphi
MSFL1_Get Secur i t yLockedSt at us( hSecur i t y : HSECURI TY;
Var pi LockSt at us : i nt eger ;
Var pui LockType : UI NT) : i nt eger ;
PowerBASIC
MSFL1_Get Secur i t yLockedSt at us( BYVAL hSecur i t y AS DWORD,
pi LockSt at us As Long,
pui LockType AS DWORD) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_FOUND if the security could not be found
ID Description
hSecurity Identifies the security.
psSecurityI nfo Points to the MSFLSecurityInfo_struct structure (page 82) that receives
the security information. The dwTotalSize member must be set to the
structure size before calling MSFL1_GetSecurityInfo.
MetaStock
Parameters
Remarks
Initializes the MetaStock File Library by creating the internal tables and buffers.
Once the MSFL is successfully initialized, it cannot be initialized again without first
shutting down. Also, if the application successfully initializes the MSFL, it must shut
down the MSFL (via MSFL1_Shutdown (page 124) before exiting. Failure to do so
may cause corruption of files and memory leaks. It may also keep directories open
and securities locked.
The application and user names constitute the MSFL user ID. The MSFL user ID is
used to distinguish between users in a data directory. By including the application
name, the same user can access the same directory with two different applications
(e.g. MetaStock and The DownLoader).
Note: Before calling this function, you must setup the key structure as documented in the
Initialization section (page 87).
See Also
MSFL1_GetMSFLState (page 107)
MSFL1_Shutdown (page 124)
MSFL1_LockSecurity
C
i nt MSFL1_LockSecur i t y( HSECURI TY hSecur i t y,
UI NT ui LockType)
Visual Basic
MSFL1_LockSecur i t y( ByVal hSecur i t y As Long,
ByVal ui LockType As Long) As Long
Delphi
MSFL1_LockSecur i t y( hSecur i t y : HSECURI TY;
ui LockType : UI NT) : i nt eger ;
PowerBASIC
MSFL1_LockSecur i t y( BYVAL hSecur i t y AS DWORD,
BYVAL ui LockType AS DWORD) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_TOO_MANY_SEC_LOCKED if the application attempted to lock
more than the maximum number of securities
(i.e. MSFL_MAX_LOCKED_SECURITIES)
MSFL_ERR_SECURITY_LOCKED if the security is locked by this or another
application
ID Description
pszAppName Points to a null-terminated string that contains the application name.
The maximum length of the application name is defined by
MSFL_MAX_APP_NAME_LENGTH.
pszUserName Points to a null-terminated string that contains the user name.
The maximum length of the user name is defined by
MSFL_MAX_USER_NAME_LENGTH.
iI nterfaceVersion Indicates the MSFL DLL interface version. The current DLL interface
version is defined by MSFL_DLL_INTERFACE_VERSION and can
simply be passed into the MSFL1_Initialize function.
MetaStock
Remarks
Constructs an MSFL date from its components: day, month and year.
See Also
MSFL1_FormatDate (page 94)
MSFL1_GetDayMonthYear (page 98)
MSFL1_MakeMSFLTime (page 118),
MSFL1_ParseDateString (page 120)
MSFL1_MakeMSFLTime
C
i nt MSFL1_MakeMSFLTi me( l ong *pl Ti me,
WORD wHour ,
WORD wMi n,
WORD wTi cks) ;
Visual Basic
MSFL1_MakeMSFLTi me( pl Ti me As Long,
ByVal wHour As I nt eger ,
ByVal wMi n As I nt eger ,
ByVal wTi cks As I nt eger ) As Long
Delphi
MSFL1_MakeMSFLTi me( Var pl Ti me : l ongi nt ;
wHour : wor d;
wMi n : wor d;
wTi cks : wor d) : i nt eger ;
PowerBASIC
MSFL1_MakeMSFLTi me( pl Ti me As Long,
BYVAL wHour As Wor d,
BYVAL wMi n As Wor d,
BYVAL wTi cks As Wor d) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_TIME if the constructed time is invalid
Parameters
Remarks
Constructs an MSFL time from its components: hour, minutes and ticks.
wYear The year. The year can be two or four digits. If the year is two digits, the
Windows cutoff year is used to determine the century. If the Windows cutoff
year is not found in the registry, a default cutoff year of twenty-nine is used.
In other words, if the two-digit year is less than or equal to twenty-nine,
MSFL1_MakeMSFLDate (page 117) will assume the century to be 2000.
If the two-digit year is greater than twenty-nine, a century of 1900 will be
assumed.
ID Description
plTime Points to a long that receives the MSFL time.
wHour The hour; must be in 24-hour format.
wMin The minutes.
wTicks The ticks. In cases where the ticks are unknown or not relevant, pass in zero for
the ticks.
ID Description
MetaStock
Remarks
Opens the specified directory.
Directories that do not contain MetaStock files can be opened; however, the
MSFL_MSG_NOT_A_METASTOCK_DIR message is returned and any MSFL
functions that operate with security or price data cannot be used.
The number of concurrent open directories is limited to
MSFL_MAX_OPEN_DIRECTORIES.
See Also
MSFL1_CloseDirectory (page 92)
MSFL1_GetDirectoryNumber (page 99)
MSFL1_GetDirectoryStatus (page 100)
MSFL1_GetLastFailedOpenDirInfo (page 106)
MSFL1_ParseDateString
C
i nt MSFL1_Par seDat eSt r i ng( l ong *pl Dat e,
LPCSTR pszDat eSt r i ng) ;
Visual Basic
MSFL1_Par seDat eSt r i ng( pl Dat e As Long,
ByVal pszDat eSt r i ng As St r i ng) As Long
Delphi
MSFL1_Par seDat eSt r i ng( Var pl Dat e : l ongi nt ;
pszDat eSt r i ng : LPCSTR) : i nt eger ;
PowerBASIC
MSFL1_Par seDat eSt r i ng( pl Dat e As Long,
pszDat eSt r i ng AS ASCI I Z) As Long
iDirOpenFlags Specifies the open flags. The flags provide additional tasks to perform
while opening the directory. Many of the tasks are provided to recover
from common errors. Multiple flags can be passed in by simply bitwise
OR-ing the flags (e.g. MSFL_DI R_ALLOW_MULTI _OPEN |
MSFL_DI R_MERGE_DUP_SECS). The MSFL_DIR_NO_FLAGS is
ignored when any other flags are used; the remaining flags can be used in
any combination.
Following is a list of the available directory open flags.
MSFL_DIR_NO_FLAGS Standard directory open. Return an error if the
directory doesnt exist, if the user is already in the directory, or if there are
duplicate securities in the directory.
MSFL_DIR_FORCE_USER_IN Open a directory that is already open by
a user with the same application and user name. This situation can occur if
the application terminated without closing the directory or if another user
on the network is using the application with the same user name. This flag
should only be used in response to the
MSFL_ERR_USER_ID_ALREADY_IN_DIR error.
MSFL_DIR_MERGE_DUP_SECS If the directory contains duplicate
securities, merge the price data for all the duplicate securities. This flag is
generally used in response to the
MSFL_ERR_DUPLICATE_SECURITIES error.
MSFL_DIR_ALLOW_MULTI_OPEN Allows the application to open the
same directory multiple times. The MSFL keeps reference count each
time the directory is opened the reference count is incremented, each time
the directory is closed the reference count is decremented. When the
reference count is equal to zero, the directory is closed.
ID Description
MetaStock
Remarks
Constructs an MSFL time from the time string. If the time is read right-to-left, all
fields must be present (i.e., the ticks/seconds, minutes, hours). If the time is read left-
to-right, the minutes and ticks/seconds are optional. The time may be in either 24-
hour format or 12-hour format. If the time is in 12-hour format, the PM symbol must
be included in the time string.
See Also
MSFL1_FormatTime (page 95)
MSFL1_GetHourMinTicks (page 104)
MSFL1_MakeMSFLTime (page 118),
MSFL1_ParseDateString (page 120)
MSFL1_ReadDataRec
C
i nt MSFL1_ReadDat aRec( HSECURI TY hSecur i t y,
MSFLPr i ceRecor d_st r uct *psPr i ceRec)
Visual Basic
MSFL1_ReadDat aRec( ByVal hSecur i t y As Long,
psPr i ceRec As MSFLPr i ceRecor d_st r uct ) As Long
Delphi
MSFL1_ReadDat aRec( hSecur i t y : HSECURI TY;
Var psPr i ceRec : MSFLPr i ceRecor d_st r uct ) : i nt eger ;
PowerBASIC
MSFL1_ReadDat aRec( BYVAL hSecur i t y AS DWORD,
psPr i ceRec AS MSFLPr i ceRecor d_st r uct ) As Long
Locking
Prevent Write Lock
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_END_OF_FILE if the current data position is past the end of the file
Parameters
Remarks
Reads the price record at the current data position.
If successful, the current data position is advanced to the next record.
See Also
MSFL2_ReadBackMultipleRecs (page 126)
MSFL2_ReadDataRec (page 127)
MSFL2_ReadMultipleRecs (page 128)
MSFL2_ReadMultipleRecsByDates (page 129)
ID Description
hSecurity Identifies the security.
psPriceRec Points to an MSFLPriceRecord_struct structure (page 84) that receives
the price record.
MetaStock
See Also
MSFL1_FindDataDate (page 92)
MSFL1_FindDataRec (page 93)
MSFL1_GetCurrentDataPos (page 96)
MSFL1_SeekBeginData (page 123)
MSFL1_Shutdown
C
i nt MSFL1_Shut down( voi d)
Visual Basic
MSFL1_Shut down( ) As Long
Delphi
MSFL1_Shut down : i nt eger ;
PowerBASIC
MSFL1_Shut down( ) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_NOT_INITIALIZED if the MSFL is not initialized
Parameters
None
Remarks
Shuts down the previously initialized MetaStock file library. During shutdown, all
open files are closed and the internal tables and buffers are freed.
See Also
MSFL1_GetMSFLState (page 107)
MSFL1_Initialize (page 115)
MSFL1_UnlockSecurity
C
i nt MSFL1_Unl ockSecur i t y( HSECURI TY hSecur i t y)
Visual Basic
MSFL1_Unl ockSecur i t y( ByVal hSecur i t y As Long) As Long
Delphi
MSFL1_Unl ockSecur i t y( hSecur i t y : HSECURI TY) : i nt eger ;
PowerBASIC
MSFL1_Unl ockSecur i t y( BYVAL hSecur i t y AS DWORD) As Long
Locking
None
Return Values
MSFL_NO_ERR if successful
MSFL_ERR_SECURITY_NOT_LOCKED if the security is not locked
Parameters
ID Description
hSecurity Identifies the security to unlock.
MetaStock
Remarks
Gets the security handles for a block of securities.
See Also
MSFL1_GetFirstSecurityInfo (page 103)
MSFL1_GetLastSecurityInfo (page 106)
MSFL1_GetNextSecurityInfo (page 108)
MSFL1_GetPrevSecurityInfo (page 109)
MSFL1_GetSecurityCount (page 111)
MSFL1_GetSecurityInfo (page 113)
MSFL2_ReadBackMultipleRecs
C
i nt MSFL2_ReadBackMul t i pl eRecs( HSECURI TY hSecur i t y,
MSFLPr i ceRecor d_st r uct *pasPr i ceRec,
const Dat eTi me_st r uct *psLast RecDat e,
WORD *pwReadCount ,
i nt i Fi ndMode)
Visual Basic
MSFL2_ReadBackMul t i pl eRecs( ByVal hSecur i t y As Long,
pasPr i ceRec As MSFLPr i ceRecor d_st r uct ,
psLast RecDat e As Dat eTi me_st r uct ,
pwReadCount As I nt eger ,
ByVal i Fi ndMode As Long) As Long
Delphi
MSFL2_ReadBackMul t i pl eRecs( hSecur i t y : HSECURI TY;
Var pasPr i ceRec: MSFLPr i ceRecor d_st r uct ;
const psLast RecDat e : Dat eTi me_st r uct ;
Var pwReadCount : wor d;
i Fi ndMode : i nt eger ) : i nt eger ;
PowerBASIC
MSFL2_ReadBackMul t i pl eRecs( BYVAL hSecur i t y AS DWORD,
pasPr i ceRec AS MSFLPr i ceRecor d_st r uct ,
psLast RecDat e AS Dat eTi me_st r uct ,
pwReadCount As Wor d,
BYVAL i Fi ndMode As Long) As Long
Locking
Prevent Write Lock
Return Values
MSFL_MSG_LESS_RECORDS_READ if successful, but fewer records were read
than requested
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_RECORDS if the read count is invalid
MSFL_ERR_END_OF_FILE if the current data position is past the end of the file
MSFL_ERR_SECURITY_HAS_NO_DATA if the security has no price records
Parameters
ID Description
hSecurity Identifies the security.
pasPriceRec Points to an MSFLPriceRecord_struct structure (page 84) array that
receives the price records.
psLastRecDate Points to a DateTime_struct structure (page 81) that contains the
date/time of the record at which to start reading.
MetaStock
Parameters
Remarks
Reads a price record for the specified date/time.
This function is equivalent to calling MSFL1_FindDataDate (page 92) to find the
date/time and then calling MSFL1_ReadDataRec (page 122) to read the price record.
See Also
MSFL1_ReadDataRec (page 122)
MSFL2_ReadBackMultipleRecs (page 126)
MSFL2_ReadMultipleRecs (page 128)
MSFL2_ReadMultipleRecsByDates (page 129)
MSFL2_ReadMultipleRecs
C
i nt MSFL2_ReadMul t i pl eRecs( HSECURI TY hSecur i t y,
MSFLPr i ceRecor d_st r uct *pasPr i ceRec,
const Dat eTi me_st r uct *psFi r st RecDat e,
WORD *pwReadCount ,
i nt i Fi ndMode)
Visual Basic
MSFL2_ReadMul t i pl eRecs( ByVal hSecur i t y As Long,
pasPr i ceRec As MSFLPr i ceRecor d_st r uct ,
psFi r st RecDat e As Dat eTi me_st r uct ,
pwReadCount As I nt eger ,
ByVal i Fi r st Fi ndMode As Long) As Long
Delphi
MSFL2_ReadMul t i pl eRecs( hSecur i t y : HSECURI TY;
Var pasPr i ceRec : MSFLPr i ceRecor d_st r uct ;
const psFi r st RecDat e : Dat eTi me_st r uct ;
Var pwReadCount : wor d;
i Fi ndMode : i nt eger ) : i nt eger ;
PowerBASIC
MSFL2_ReadMul t i pl eRecs( BYVAL hSecur i t y AS DWORD,
pasPr i ceRec AS MSFLPr i ceRecor d_st r uct ,
psFi r st RecDat e AS Dat eTi me_st r uct ,
pwReadCount As Wor d,
BYVAL i Fi ndMode As Long) As Long
Locking
Prevent Write Lock
ID Description
hSecurity Identifies the security.
psRecordDate Points to a DateTime_struct structure (page 81) that contains the
date/time of the record to read.
psPriceRec Points to an MSFLPriceRecord_struct structure (page 84) that receives
the price record.
iFindMode Indicates what type of search to perform to locate the price record to read.
Following are the different modes available.
MSFL_FIND_CLOSEST_PREV
If an exact match is not found, find the previous closest record.
MSFL_FIND_CLOSEST_NEXT
If an exact match is not found, find the next closest record.
MSFL_FIND_EXACT_MATCH
Find an exact date/time match.
MSFL_FIND_USE_CURRENT_POS
Skip the find and use the current position. When this mode is used, the
contents of psRecordDate are ignored.
MetaStock
Delphi
MSFL2_ReadMul t i pl eRecsByDat es( hSecur i t y : HSECURI TY;
Var pasPr i ceRec : MSFLPr i ceRecor d_st r uct ;
const psFi r st RecDat e : Dat eTi me_st r uct ;
const psLast RecDat e : Dat eTi me_st r uct ;
Var pwMaxReadCount : wor d;
i Fi r st Fi ndMode : i nt eger ) : i nt eger ;
PowerBASIC
MSFL2_ReadMul t i pl eRecsByDat es( BYVAL hSecur i t y AS DWORD,
pasPr i ceRec AS MSFLPr i ceRecor d_st r uct ,
psFi r st RecDat e AS Dat eTi me_st r uct ,
psLast RecDat e AS Dat eTi me_st r uct ,
pwMaxReadCount As Wor d,
BYVAL i Fi r st Fi ndMode As Long) As Long
Locking
Prevent Write Lock
Return Values
MSFL_MSG_LESS_RECORDS_READ if successful, but fewer records were read
than requested
MSFL_MSG_MORE_RECORDS_IN_RANGE if successful, but there were more
records in the date range than the array could hold
MSFL_NO_ERR if successful
MSFL_ERR_INVALID_RECORDS if the read count is invalid
Parameters
Remarks
Reads the price record(s) for the date range indicated. It stops reading when it reaches
a price record with a date/time greater than psLastDate or when the maximum
number of records have been read. If successful, the current data position is set to the
next price record.
See Also
MSFL1_ReadDataRec (page 122)
MSFL2_ReadBackMultipleRecs (page 126)
MSFL2_ReadDataRec (page 127)
MSFL2_ReadMultipleRecs (page 128)
ID Description
hSecurity Identifies the security.
pasPriceRec Points to an MSFLPriceRecord_struct structure (page 84) array
that receives the price records.
psFirstRecDate Points to a DateTime_struct structure (page 81) that contains the
date/time of the record at which to start reading.
psLastRecDate Points to a DateTime_struct structure (page 81) that contains the
date/time of the record at which to stop reading.
pwMaxReadCount Points to a WORD that contains the maximum number of records to
read (i.e. the maximum number of records the array can hold). It also
receives the actual number of records read.
iFirstFindMode Indicates what type of search to perform to locate the first price
record to read. Following are the different modes available.
MSFL_FIND_CLOSEST_PREV
If an exact match is not found, find the previous closest record.
MSFL_FIND_CLOSEST_NEXT
If an exact match is not found, find the next closest record.
MSFL_FIND_EXACT_MATCH
Find an exact date/time match.
MetaStock
-368: MSFL_ERR_ALREADY_A_MS_DIR
Attempted to build MetaStock files in an existing MetaStock directory.
-367: MSFL_ERR_NOT_A_MS_DIR
The directory is not a MetaStock directory.
-366: MSFL_ERR_DIR_IS_BUSY
The files are in a state where only one user can access them.
-365: MSFL_ERR_USER_ID_ALREADY_IN_DIR
This user ID (i.e. program and user name) already has this directory open.
-364: MSFL_ERR_TOO_MANY_USERS_IN_DIR
The maximum number of users have already opened the directory.
-363: MSFL_ERR_INVALID_USER
The user is invalid because another user with the same application name and user
name opened the directory.
-362: MSFL_ERR_NON_MSFL_USER_IN_DIR
The directory is in use by a non-MSFL application, the data cannot be accessed
until the single user application is finished.
-361: MSFL_ERR_DIR_IS_READ_ONLY
The directory is read-only; therefore, the operation cannot be performed.
-360: MSFL_ERR_MAX_FILES_IN_TEMP_DIR
Too many MSFL files exist in the Windows temp directory.
-355: MSFL_ERR_INVALID_XMASTER_FILE
The XMASTER file is corrupt.
-354: MSFL_ERR_INVALID_INDEX_FILE
The index file is corrupt.
-353: MSFL_ERR_INVALID_LOCK_FILE
The lock file is corrupt.
-352: MSFL_ERR_INVALID_SECURITY_FILE
The security file is corrupt.
-351: MSFL_ERR_INVALID_USERS_FILE
The user file is corrupt.
-350: MSFL_ERR_CRC_ERROR
A CRC error occurred while accessing a file.
-349: MSFL_ERR_DRIVE_NOT_READY
The drive is not ready.
-348: MSFL_ERR_GENERAL_FAILURE
A general failure occurred while accessing the disk.
-347: MSFL_ERR_MISC_DISK_ERROR
A general disk error occurred while accessing the disk.
-346: MSFL_ERR_SECTOR_NOT_FOUND
Sector not found.
-345: MSFL_ERR_SEEK_ERROR
An error occurred while seeking in the file.
-344: MSFL_ERR_UNKNOWN_MEDIA
Unknown disk media type.
-343: MSFL_ERR_WRITE_PROTECTED
The disk is write protected.
MetaStock
-249: MSFL_ERR_UNABLE_TO_RESYNCH
Unable to resynchronize the security files.
-248: MSFL_ERR_FILES_IN_DIR_CHANGED
The files in the directory have changed (i.e. they are not the same files the directory
was opened with).
-247: MSFL_ERR_UNRECOGNIZED_VERSION
The MetaStock files are not a recognized version.
-225: MSFL_ERR_INVALID_COMP_SYMBOL
The composite symbol is invalid.
-224: MSFL_ERR_INVALID_SYMBOL
The ticker symbol is invalid.
-200: MSFL_ERR_DIFFERENT_DATA_FORMATS
The securities are of different data formats (i.e. the periodicity, interval, or price
fields of the securities do not match).
-199: MSFL_ERR_DUPLICATE_SECURITIES
Attempted to open a directory that contains duplicate securities.
-198: MSFL_ERR_DUPLICATE_SECURITY
Adding the security would duplicate an existing security.
-197: MSFL_ERR_PRIMARY_SEC_NOT_FOUND
The primary security of the composite cannot be found.
-196: MSFL_ERR_SECONDARY_SEC_NOT_FOUND
The secondary security of the composite cannot be found.
-195: MSFL_ERR_SECURITY_HAS_COMPOSITES
Security cannot be deleted because there are one or more composites that depend
on the security.
-194: MSFL_ERR_SECURITY_HAS_NO_DATA
There is no price data for the security.
-193: MSFL_ERR_SECURITY_IS_A_COMPOSITE
Security is a composite.
-192: MSFL_ERR_SECURITY_NOT_COMPOSITE
Security is not a composite.
-191: MSFL_ERR_SECURITY_NOT_FOUND
The security was not found in the directory.
-190: MSFL_ERR_TOO_MANY_SECURITIES
The maximum number of securities per directory has already been reached; adding
additional securities is not possible.
-189: MSFL_ERR_TOO_MANY_COMPOSITES
The maximum number of composites per directory has already been reached.
-188: MSFL_ERR_SECURITIES_ARE_THE_SAME
The securities are the same security. Attempted to merge the security with itself.
-175: MSFL_ERR_INVALID_DATE
The date is invalid.
-174: MSFL_ERR_INVALID_TIME
The time is invalid.
-173: MSFL_ERR_INVALID_INTERVAL
The interval is invalid.
MetaStock
Message Codes
The following is list of the possible message codes that can be returned from some
MSFL functions. The message codes are positive return codes; whereas the error codes
are negative return codes. Thus, if an MSFL function is successful the error will be
equal to or greater than MSFL_NO_ERR.
0: MSFL_NO_MSG
No message.
1: MSFL_MSG_NOT_A_MetaStock_DIR
Not a MetaStock data directory.
2: MSFL_MSG_CREATED_DIR
Created directory.
3: MSFL_MSG_BUILT_MetaStock_DIR
Created empty MetaStock files in the directory.
4: MSFL_MSG_CREATED_N_BUILT_DIR
Created directory and empty MetaStock files.
5: MSFL_MSG_FIRST_SECURITY_IN_DIR
This is the first security in the directory.
6: MSFL_MSG_LAST_SECURITY_IN_DIR
This is the last security in the directory.
25: MSFL_MSG_NOT_AN_EXACT_MATCH
The record found was not an exact match.
50: MSFL_MSG_OVERWROTE_RECORDS
Overwrote existing records.
51: MSFL_MSG_LESS_RECORDS_DEL
Fewer records were deleted than requested.
52: MSFL_MSG_LESS_RECORDS_READ
Fewer records were read than requested.
53: MSFL_MSG_MORE_RECORDS_IN_RANGE
There are more records within the specified date range.
MetaStock
M
Message codes 88, 136
MSFL data types 81
MSFL function levels 77
MSFL functions
listed by name 89
listed by type 90
MSFL notations 81
MSFL_DISPLAY_UNITS_DECIMAL 83
MSFL_DLL_INTERFACE_VERSION 116
MSFL_ERR_MSFL_CORRUPT 88
MSFL_ERR_NON_MSFL_USER_IN_DIR 106
MSFL_LOCK_FULL_LOCK 87
MSFL_LOCK_PREV_WRITE_LOCK 87
MSFL_LOCK_WRITE_LOCK 87
MSFL_MAX_APP_NAME_LENGTH 116
MSFL_MAX_DISPLAY_UNITS 83
MSFL_MAX_INTERVAL 83
MSFL_MAX_NAME_LENGTH 83
MSFL_MAX_READ_WRITE_RECORDS 129
MSFL_MAX_SYMBOL_LENGTH 80, 83
MSFL_MAX_USER_NAME_LENGTH 116
MSFL_MIN_DISPLAY_UNITS 83
MSFL_MIN_INTERVAL 83
MSFL_MSG_NOT_A_METASTOCK_DIR 120
MSFL_NO_ERR 88
MSFL_VALID_OPERATORS 83
MSFL_VALID_PERIODICITIES 83
MSFL1_GetErrorMessage 102
MSFL1_Initialize, described 115
MSFLDirectoryStatus_struct 101
defined 101
MSFLSecurityIdentifier_struct 112
defined 112
Multi-user 78
N
notations used by the MSFL 81
P
Price data 80
field combinations 80
mnemonics 80
Price record structure 84
Primary security 78
psLastDate 130
R
Removable media 77
Return codes. See Error codes.
S
Secondary security 78
Securities
composite 78
duplicate 88, 120
Security handle 81
Security identifier structure 112
Security information structure 82
Shutdown 87, 124
Structures
date time 81
price record 84
security information 82
Symbol 80
T
Technical support 77
Times 79
V
variable notation 81
W
wDataAvailable 80, 84, 85
MetaStock
Index 141
Index
Symbols
~MSXIMPORTDLLS~ 16
A
Advise Callbacks, DDE 19
Advise Requests, DDE 19
Application development
C/C++ 75
Delphi 76
PowerBASIC 76
samples 3
Visual Basic 76
Application, DDE 17, 18
Argument range tests 53
Ask, DDE Item 18
Asksize, DDE Item 18
B
Bid, DDE Item 18
Bidsize, DDE Item 18
Borland C++ 5.0
Creating an MSX DLL 43
Debugging an MSX DLL 46
Borland C++ Builder 4.0
Creating an MSX DLL 41
Debugging an MSX DLL 46
Borland Delphi Pascal
Creating an MSX DLL 43
Debugging an MSX DLL 46
C
C
Creating an MSX DLL 40, 41, 43
Debugging an MSX DLL 45, 46
Sample DLL Program 63
Calculation Functions 30
Calculation Structures 35
MSXDataInfoRec 35
MSXDataRec 36
MSXDateTime 35
CD-ROM support 79
CF_TEXT 18, 20
Change, DDE Item 18
closing EqDdeSrv with active conversations 19
Cold-link 17, 19
Command line switches in EqCustUI 12
compatibility of Formula Organizer 14
compilers supported 2
Composite 78
primary security 78
record numbers 78
secondary security 78
Connections, DDE 19
Copyright information 13, 15
custom strings, and partial matches 34
Custom toolbar 5
D
Data
Data Array 56
Price Data 58
Sample 48
Types 31
data array
Argument range 53
tests
Max/Min 52
Special Case 52
data field mnemonics 80, 84
Data Requests, DDE 19
Data Server 17
Data Types 31
Dates 31
in MSFL 81
Strings 31
Times 31
Date Time structure 81
Date, DDE Item 18
Dates 79
DDE Advise Callbacks 19
DDE Advise Requests 19
DDE Application 17, 18
DDE Connections 19
DDE Data Requests 19
DDE Item 17
Ask 18
Asksize 18
Bid 18
Bidsize 18
142 Index MetaStock
Change 18
Date 18
High 18
Last 18
Low 18
Open 18
Openint 18
Prevclose 18
Time 18
Totalvol 18
Tradevol 18
Ydtotalvol 18
DDE Server 17
DDE Service 17
DDE System Requests 19
DDE System Topic 19, 20
Formats 20
Status 20
SysItems 20
TopicItemList 20
DDE Topic 17, 18
Directory
closing 87
number 87
opening 87
distributing your MSX DLL 60
DOP files 79
Duplicate
securities 120
duplicate securities 88
E
EqCustUI 5
C/C++ example 6
locking MetaStock files 5
EqCustUI utility 5
EqDatSrv 17
EqDatSrv Updates 19
EqDatSrv.exe 17
EqDdeSrv, closing with active conversations 19
EqDdeSrv.exe 17
Equis Data Server 17
Equis Dynamic Data Exchange Server 17
Error
codes 88, 131
codes in EqCustUI 12
handling 88
Excel 17
DDE Example for 20
Export
DLLs 13
formula-based tools 13
templates 13
External Function DLL folder 16
ExtFml 26, 32, 34
F
Field combinations 80
File
reserved names 79
types 79
Folder
~MSXIMPORTDLLS~ 16
External Function DLLs 16
Formats, DDE System Topic 20
Formorg.exe, detecting multiple versions 16
Formula organizer 13
exporting 14
Formula Organizer compatibility 14
FOSetup.exe 15, 16
Function Argument Structures 38
MSXCustomArgsArray 39
MSXDataInfoRecArgsArray 38
MSXNumericArgsArray 39
MSXResultRec 39
MSXStringArgsArray 39
function levels in MSFL 77
Functions
MSFL1_CloseDirectory 92
MSFL1_FindDataDate 92
MSFL1_FindDataRec 93
MSFL1_FormatDate 94
MSFL1_FormatTime 95
MSFL1_GetCurrentDataPos 96
MSFL1_GetDataPath 97
MSFL1_GetDataRecordCount 97
MSFL1_GetDayMonthYear 98
MSFL1_GetDirectoryNumber 99
MSFL1_GetDirectoryStatus 100
MSFL1_GetDirNumberFromHandle 100
MSFL1_GetErrorMessage 102
MSFL1_GetFirstSecurityInfo 103
MSFL1_GetHourMinTicks 104
MSFL1_GetLastFailedLockInfo 87, 105
MSFL1_GetLastFailedOpenDirInfo 106
MSFL1_GetLastSecurityInfo 106
MSFL1_GetMSFLState 107
MSFL1_GetNextSecurityInfo 108
MSFL1_GetPrevSecurityInfo 109
MSFL1_GetRecordCountForDateRange 110
MSFL1_GetSecurityCount 111
MSFL1_GetSecurityHandle 111
MSFL1_GetSecurityID 112
MSFL1_GetSecurityInfo 113
MSFL1_GetSecurityLockedStatus 114
MSFL1_Initialize 115
MSFL1_LockSecurity 116
MSFL1_MakeMSFLDate 117
MSFL1_MakeMSFLTime 118
MetaStock
Index 143
MSFL1_OpenDirectory 119
MSFL1_ParseDateString 120
MSFL1_ParseTimeString 121
MSFL1_ReadDataRec 122
MSFL1_SeekBeginData 123
MSFL1_SeekEndData 123
MSFL1_Shutdown 87, 124
MSFL1_UnlockSecurity 124
MSFL2_GetSecurityHandles 125
MSFL2_ReadBackMultipleRecs 126
MSFL2_ReadDataRec 127
MSFL2_ReadMultipleRecs 128
MSFL2_ReadMultipleRecsByDates 129
H
Help 26
Help menu in MetaStock 5
High, DDE Item 18
Hot-link 17, 19
HSECURITY 81, 112
I
iFirstValid 30, 35
defined 35
iFirstValid setting 58
iLastValid 30, 35
defined 35
iLastValid setting 58
iLastValue indexes 30
Import
DLLs 13
formula-based tools 13
templates 13
Initialization Functions 27
MSXInfo 27
MSXNthArg 28
MSXNthCustomString 29
MSXNthFunction 28
Initialization Structures 32
MSXDLLDef 32
MSXFuncArgDef 33
MSXFuncCustomString 34
MSXFuncDef 32
Initialize 87, 116
key 87
initialize 22
Installation
files 3
setup 2
Installation file
creating 13, 15
installing 16
password 16
using 16
Installing third party add-ons 13
Item, DDE 17
L
Last, DDE Item 18
Library key 87
Lock types 87
full 78, 87
prevent write 78, 87
write 78, 87
locked MetaStock files 5
Locking
composite 87
directory 78
security 78, 87
Low, DDE Item 18
lTime 35, 81
M
Max/Min data array tests 52
Menu.AddItem 8
Menu.AddPopupItem 10
Menu.DeleteItem 9
Menu.DeletePopupItem 11
Message codes 88, 136
MetaStock
Custom toolbar 5
Help menu 5
loading DLLs 16
Tools menu 5
MetaStock External Function (MSX) defined 25
MetaStock files
locked 5
Microsoft Excel 17
DDE Example 20
Microsoft Visual C++
Creating an MSX DLL 40
Debugging an MSX DLL 45
MSFL data types 81
MSFL function levels 77
MSFL functions
listed by name 89
listed by type 90
MSFL notations 81
MSFL, using in an MSX DLL 60
MSFL_DISPLAY_UNITS_DECIMAL 83
MSFL_DLL_INTERFACE_VERSION 116
MSFL_ERR_MSFL_CORRUPT 88
MSFL_ERR_NON_MSFL_USER_IN_DIR 106
MSFL_LOCK_FULL_LOCK 87
144 Index MetaStock
MSFL_LOCK_PREV_WRITE_LOCK 87
MSFL_LOCK_WRITE_LOCK 87
MSFL_MAX_APP_NAME_LENGTH 116
MSFL_MAX_DISPLAY_UNITS 83
MSFL_MAX_INTERVAL 83
MSFL_MAX_NAME_LENGTH 83
MSFL_MAX_READ_WRITE_RECORDS 129
MSFL_MAX_SYMBOL_LENGTH 80, 83
MSFL_MAX_USER_NAME_LENGTH 116
MSFL_MIN_DISPLAY_UNITS 83
MSFL_MIN_INTERVAL 83
MSFL_MSG_NOT_A_METASTOCK_DIR 120
MSFL_NO_ERR 88
MSFL_VALID_OPERATORS 83
MSFL_VALID_PERIODICITIES 83
MSFL1_GetErrorMessage 102
MSFL1_Initialize, described 115
MSFLDirectoryStatus_struct 101
defined 101
MSFLSecurityIdentifier_struct 112
defined 112
MSX DLL, distributing 60
MSX_ERROR 39
MSX_MAXARGS 33, 38
MSX_MAXSTRING 32
MSX_MAXSTRING, defined 31
MSX_VERSION 32
MSXCustom 34
MSXCustomArgsArray structure 39
MSXDataInfoRec 36
MSXDataInfoRec structure 35
MSXDataInfoRecArgsArray structure 38
MSXDataRec 35
MSXDataRec structure 58
described 36
MSXDateTime 35, 36
MSXDLLDef structure 27
MSXFuncArgDef data structure 29
MSXFuncCustomString data structure 29
MSXFuncDef data structure 28
MSXNthCustomString 34
MSXNumeric arguments 38
MSXNumericArgsArray argument array 38
MSXNumericArgsArray structure 39
MSXResultRec structure 39
MSXStringArgsArray structure 39
MSXStruc.bas 32
MSXStruc.pas 32
Multi-user 78
N
notations used by the MSFL 81
O
Open, DDE Item 18
Openint, DDE Item 18
P
partial match on custom strings 34
Password
formulas 15
installation file 16
PowerBASIC
Creating an MSX DLL 44
Debugging an MSX DLL 47
Sample DLL Program 71
Prevclose, DDE Item 18
Price data 80
field combinations 80
mnemonics 80
Price record structure 84
Primary security 78
Programming Considerations
UI Restrictions 59
psLastDate 130
R
Registry 18
Removable media 77
Return codes. See Error codes.
S
Sample
applications 3
data 3
sClose data array 58
Secondary security 78
Securities
composite 78
duplicate 88, 120
Security handle 81
Security identifier structure 112
Security information structure 82
Service, DDE 17
Setup key 2
MetaStock
Index 145
Shutdown 87, 124
sInd structure 36
Snapshot 17
Special Case data array tests 52
Status, DDE System Topic 20
string format in DDE Server 18
strings, and partial matches 34
Structures
date time 81
price record 84
security information 82
supported compilers 2
Symbol 80
SysItems, DDE System Topic 20
System Requests, DDE 19
System Requirements 2
System Topic, DDE 19, 20
T
Tech Notes
Using MSFL in an MSX DLL 60
Technical support 4, 26, 77
Templates
exporting 13
importing 13
Testing
MSXTest 48
Stress Testing 52
Testing your DLL with MetaStock 55
Time, DDE Item 18
Times 79
Toolbar.Add 7
Toolbar.Delete 8
Tools menu in MetaStock 5
Topic, DDE 17, 18
TopicItemList, DDE System Topic 20
Totalvol, DDE Item 18
Tradevol, DDE Item 18
typographic conventions 2
U
User interface 5
V
Variable Notation 31
variable notation 81
Visual Basic 25
W
wDataAvailable 80, 84, 85
Win32 43
Win32 DLL 25
Y
Ydtotalvol, DDE Item 18