This is the second part of a three part blog entry in which we review the answers to some of the most common questions that arise when developing or using a TradeStation-compatible DLL for the first time:
1) Where can I find C++ code for a sample TradeStation-compatible DLL?
Please have a look at the following examples.
Here is a demonstration that illustrates how EasyLanguage can use its DLL interface to communicate with Microsoft Excel®. ELExcel.dll is one of the DLL coding demonstrations we provide to illustrate how the EasyLanguage interface to DLL’s works. Unlike previous demonstrations, use of this DLL does not require any coding on the “Excel side”. Instead, all action is controlled by EasyLanguage.
Separate “wrapper functions” are provided that demonstrate the TradeStation to DLL interface by:
- Initializing the Excel application for interaction with EasyLanguage.
- Designating a specific Excel worksheet as the one to be used for a series of other EasyLanguage commands.
- Placing values of various data types (numbers, strings, Boolean values) into Excel cells.
- Retrieving values of various data types from Excel cells.
- Setting the cell background color and font color to be used in an Excel cell.
- Clearing values and formatting from a specific Excel cell or from an entire Excel worksheet.
Current Zip Files
These zip files contain the updated DLL and DLL source files, along with the updated Demo 2 workspace.
Original (legacy) Zip Files + New Zip File 3
These zip files contain the original DLL and DLL source files. Zip File 3 contains the original DLL file, but has an updated version of the Demo 2 workspace.
After clicking on a zip file link above, select “Save” (when prompted) in order to save the zip file to your local hard-drive. Use a utility such as WinZip® to decompress the file.
Please be sure to open the documentation file, which comes in Zip File 2, and review it before doing anything else. The name of the documentation file is “Excel Link DLL – Version 1.3.doc”. The documentation file contains complete installation instructions, along with detailed documentation of the provided functions and of the demonstration workspaces.
Here is the latest release of GlobalVariable.dll – one of the DLL coding demonstrations we provide for those who wish to create TradeStation-compatible DLL’s. It is backward compatible with the demonstrations provided for Global Variables 2.1.
The attached zip file contains the following:
- New documentation (contained in the file “Global Variable 2.2.doc”)
- Two demonstration workspaces
- An ELD file containing studies and functions for import
- C++ project and code files
- GlobalVariable.dll (compiled from the new Version 2.2 code)
After clicking on the zip file link above, select “Save” (when prompted) in order to save the zip file to your local hard-drive. Use a utility such as WinZip® to decompress the file.
In bullet form, here’s what’s new in this version. Please see the documentation contained in the zip files for more detail:
- Added a new type of global variables, Boolean global variables.
- Added functions to demonstrate storage and retrieval of numbered and named global variables of Boolean type.
- Added functions to “reset” or “reinitialize” named global variables. GV_ResetAllNmd(Type) functions demonstrate how all named global variables of a given type name can have their names reset to NULL and their values reset to initial values (0 for numeric global variables, NULL for string global variables, and FALSE for Boolean global variables).
- Added GV_Get(Type)NameByNum functions to demonstrate retrieval of the name of a named variable based on the named variable’s element location number.
- Added GV_GetNamed(Type)ByNum functions to demonstrate retrieval of the value stored in a named variable based on the named variable’s element location number.
- Modified return type of all functions that return strings so that they return BSTR’s rather than LPSTR’s to demonstrate DLL code that can be used with applications that use BSTR’s rather than LPSTR’s.
- Expanded the interprocess data segment for string global variables from 3000 locations to 10,000 locations to better demonstrate storage of numbered string global variables.
- Added internal function fnGenRunTimeError to demonstrate the ability to generate a run-time error in TradeStation under appropriate circumstances using the functionality included in the EasyLanguage Extension SDK (tskit.dll).
- Added Version.rc resource file to the DLL project to allow for easy retrieval of GlobalVariable.dll version information (for example, using Windows Explorer)
Please refer to the extensive documentation file, “Global Variable 2.2.doc”, which is included in the download package, for installation instructions and an introduction to how the global variable code works.
2) What is the scope of the variables in my DLL? In Windows®, a DLL is loaded into the address space of the calling process.
All DLL variables are local to that process. In TradeStation, the two processes most commonly used with EasyLanguage are Charting and RadarScreen. Variables of global DLL scope are shared by all analysis techniques that run within one or the other of these processes. For example, all global DLL variables that appear within a DLL called from an EasyLanguage analysis technique running in Charting will be visible to all analysis techniques that run in Charting. The same is true of RadarScreen. However, DLL variables of global DLL scope are not visible across process lines unless a special interprocess communication method is implemented.
3) How do I avoid sharing DLL variables of global scope with other EasyLanguage analysis techniques that run in the same process?
In this case, variables should not be declared with global scope in the DLL. Instead, you can write a class that contains your “instance-specific” properties. Then, you can store an instance of this class in the IEasyLanguageProperties interface provided by the EasyLanguage Extension SDK. This provides a means of managing the “context” of each analysis technique within a process.