EasyLanguage Extension SDK
EasyLanguage Extension SDK
TradeStation Securities, Inc. seeks to serve institutional and active traders. Please be advised that
active trading is generally not appropriate for someone of limited resources, limited investment or
trading experience, or low risk tolerance, or who is not willing to risk at least $50,000 of capital.
This book discusses in detail how TradeStation is designed to help you develop, test and
implement trading strategies. However, TradeStation Securities does not provide or suggest
trading strategies. We offer you unique tools to help you design your own strategies and look at
how they could have performed in the past. While we believe this is very valuable information,
we caution you that simulated past performance of a trading strategy is no guarantee of its future
performance or success. We also do not recommend or solicit the purchase or sale of any
particular securities or securities derivative products. Any securities symbols referenced in this
book are used only for the purposes of the demonstration, as an example ---- not a
recommendation.
Finally, this book shall discuss automated electronic order placement and execution. Please note
that even though TradeStation has been designed to automate your trading strategies and deliver
timely order placement, routing and execution, these things, as well as access to the system itself,
may at times be delayed or even fail due to market volatility, quote delays, system and software
errors, Internet traffic, outages and other factors.
Options trading is not suitable for all investors. Your account application to trade options will be considered and approved or
disapproved based on all relevant factors, including your trading experience. Automated trading, as it relates to direct-access
electronic placement and execution of equity options trades, requires manual one-click verification before order is sent. Please visit
www.TradeStation.com to view the document titled Characteristics and Risks of Standardized Options.
Contents
Overview
A.) EN_DATA_STREAM
B.) enDataType
C.) enPlatformType
4.) Structures
A.) TSRuntimeErrorItem
A.) IEasyLanguageObject
B.) IEasyLanguagePrice
C.) IEasyLanguageVariable
D.) IEasyLanguageDateTime
E.) ITradeStationPlatform
F.) IEasyLanguageErrors
G.) IEasyLanguageProperties
H.) IELFrameworkArray
I.) IEasyLanguageSystem
J.) IEasyLanguageServerField
Support
Overview
The EasyLanguage Extension SDK is intended for use in conjunction with
analysis techniques written in EasyLanguage. It makes it easier for you to integrate
function libraries developed in another programming language with analysis
techniques developed in EasyLanguage.
This version of the EasyLanguage SDK does not provide access to all
TradeStation reserved words, nor can functions written in EasyLanguage be called
directly. (Of course, many programming languages have run-time libraries that
perform many of the functions available through EasyLanguage reserved words,
especially mathematical functions. Market/Trading functions are a notable
exception, because of the specific nature of their use.)
The SDK does not provide the ability to plot directly on a chart, nor to directly
buy or sell. However, these functions can be performed by EasyLanguage studies or
strategies. The SDK does not provide the ability to access data from TradeStation
windows other than those into which an EasyLanguage analysis technique has been
inserted. For example, the SDK does not provide access to values shown in the
“Matrix” or “News” windows of TradeStation.
This reference provides the basic information necessary to make the SDK
functions available to your DLL, and to call your DLL functions from EasyLanguage in
a manner that will provide your DLL with the information it needs to use the SDK.
Because use of the EasyLanguage Extension SDK is an advanced topic in
EasyLanguage, this reference presumes some familiarity with EasyLanguage. Some
familiarity with C++ is presumed by the C++ code examples. Some example code
may be Visual C++® (Microsoft) specific.
1
language’s syntax requirements. When language-specific examples are provided, it
will be clear from the context that the example is language-specific.
The following is a description of the format used for all code in this document:
Courier New font – Program code is presented using the Courier New font. This
font is used to distinguish code segments from descriptive text. Also, this font is a
“monospace” font; all letters are the same width horizontally. This aids in creating
uniform spacing of code blocks.
Boldface Italic – Boldface italics are used in property or method syntax examples
to distinguish the names of the actual properties or methods being described.
Italic and boldface fonts, and parentheses, have their usual meanings when used in
this document outside code blocks.
Style Examples:
Pseudocode:
InterfaceObject.AsDouble[nBarsBack] ( = dValue;)
C++
pMyVar->AsDouble[nBarsBack] ( = 17.5475 ;)
Delphi
2
Using the SDK
The EasyLanguage Extension SDK is implemented in the file tskit.dll. This file is
installed, by default, in the \Program subdirectory of the directory into which
TradeStation is installed.
In order for your DLL to use the SDK, and to make a DLL TradeStation-
compatible, several things must be accomplished. These requirements are listed
below. Some requirements are specific to DLL’s that use the SDK. Whether a
requirement applies to all DLL’s or to only DLL’s that use the SDK is noted in the
detailed list of requirements below. Here is the list of requirements:
1.) The DLL must import tskit.dll. Every programming language has a
specific means of accomplishing this. A C++ example is provided below.
This requirement applies to the DLL only if the DLL uses the SDK. This is
not a requirement of DLL’s that do not use the SDK.
2.) The EasyLanguage analysis technique that calls the DLL function must
declare the DLL function in an external statement. This requirement
applies to the DLL only if the DLL uses the SDK. This is not a
requirement of DLL’s that do not use the SDK. If the DLL does not use
the SDK then either the external reserved word or the legacy
reserved word DefineDLLFunc may be used to declare DLL functions.
4.) The DLL must export functions using the __stdcall calling convention.
This is a requirement of all TradeStation-compatible DLL’s. It applies to
both DLL’s that use the SDK and to DLL’s that do not use the SDK.
5.) Optional: The #Events and #End compiler directives may be used in
conjunction with the reserved words OnCreate and OnDestroy to specify
DLL functions to be run when an EasyLanguage analysis technique that
calls DLL functions is activated or deactivated. This option applies only
to DLL’s that use the SDK.
3
1.) Importation of tskit.dll
In order to use the SDK, your DLL project must include a reference to tskit.dll.
As previously mentioned, tskit.dll is located, by default, in the \Program subdirectory
of the directory into which TradeStation is installed. Unlike the legacy SDK, there
are no header files included; they are not needed. To make use of the SDK, simply
include the following line in your Visual C++® DLL Project:
This #import directive results in the creation of two type library header files: a
primary header file named “tskit.tlh”, and a secondary header file named “tskit.tli”.
These files are created during DLL project compilation and are placed, by the
compiler, in the DLL project subdirectory. Both files are read and compiled as if the
primary header file had been named in an #include directive. (The secondary
header file is compiled because it is named in an #include directive at the end of the
primary header file.)
PATH is the Windows directory path to the DLL file. PATH is an optional parameter. If
a path is not specified, the subdirectory “C:\Program Files\TradeStation\Program\” is
presumed to be the subdirectory that contains the DLL file. If the DLL is not found in
the \TradeStation\Program subdirectory, then the directories in the computer’s
system path statement will be searched. If the DLL is not located in any of those
directories, a run-time error will occur.
RETURN TYPE is the data type of the value that the DLL function will return (int, bool,
double, float, etc.)
4
DLL FUNCTION NAME is a mandatory parameter of the external statement. It is the
name of the function exported by the DLL. The function name must be placed inside
quotation marks. As noted above, function names are case-sensitive when used in
the external statement but are not case-sensitive when used elsewhere in
EasyLanguage code.
It is a good practice to provide names for DLL function arguments and return
values using comment braces, as in the following external statement:
Here is some EasyLanguage code that declares a DLL function, then calls it:
inputs:
Length( 10 ) ;
variables:
int MyELVar( 0 ) ;
5
MyELVar = MyADX( self, Length ) ;
The DLL prototype for the function MyADX might look like this:
The C++ code example below illustrates the use of __stdcall notation in a function
prototype. This is the function prototype for a DLL function called EXAMPLEONCREATE, a
function which receives a pointer to an IEasyLanguageObject as its sole argument, and returns
an integer:
In place of the legacy Dll_Add and Dll_Free functions, EasyLanguage has added
support for “events”. Currently, two events are supported: “OnCreate” and
“OnDestroy”. The OnCreate event occurs when an analysis technique is first inserted
into a chart, any time a chart reload occurs, or when the status of the analysis
technique is cycled from OFF to ON. You may create functions in your DLL that can
be executed when these events occur.
Any DLL function that should be executed when an analysis technique that uses
a DLL first loads should be referenced in an OnCreate statement. Similarly, any DLL
function that should be executed when an analysis technique that uses a DLL is
disabled should be referenced in an OnDestroy statement.
6
By providing a means of executing DLL functions when an analysis technique
first loads and when it unloads, the OnCreate and OnDestroy events give
programmers a method of tracking their analysis techniques, initializing variables,
and performing housekeeping when analysis techniques that use DLL functions load
or unload.
Here is some EasyLanguage code that demonstrates that the self pointer need
not be explicitly passed to the DLL:
#events
OnCreate = EXAMPLEONCREATE ;
OnDestroy = EXAMPLEONDESTROY ;
{ Note: self pointer not explicitly passed in these two function
calls }
#end ;
Here are the prototypes for the DLL functions that will be called when the
OnCreate and OnDestroy events occur:
7
If multiple DLL functions are to be run when the OnCreate or OnDestroy events
occur, each DLL function prior to the last one to be run must return a value of zero
(or FALSE) to indicate normal completion. If a non-zero value is returned, then
subsequent functions to be run during the event will not be called.
To call multiple DLL functions when an event occurs, either of the following
syntaxes may be used:
A.) More than one function may be listed in each OnCreate and OnDestroy
statement. Functions will be executed in the order listed. Here is some
example code:
#Events
OnCreate = MyFunc1, MyFunc2, MyFunc3;
OnDestroy = MyFunc4, MyFunc5, MyFunc6;
#End
#Events
OnCreate = MyFunc1;
OnCreate = MyFunc2;
OnDestroy = MyFunc4;
OnDestroy = MyFunc5;
#End
This completes the section of this reference devoted to discussion of using the
SDK. We have discussed the five basic requirements of TradeStation-compatible
DLL’s that use the SDK. To review, those requirements are:
Below, the contents of the TSKit type library will be discussed in detail.
8
Type Library Reference
1.) Available Data Types
The following data types are supported and available for use with the
EasyLanguage Extension SDK Library:
The following Data Type keywords, available for use with the EasyLanguage
DLL Extension Kit for TradeStation 2000i and TradeStation 6, were previously
provided for future use. Please note that these words should no longer be used with
either the legacy SDK (elkit32.dll) nor the current EasyLanguage Extension SDK
(tskit.dll). This is due to the fact that the legacy platforms did not fully support their
use, and the EasyLanguage Extension SDK no longer requires them:
LPBYTE BYTE
LPDOUBLE DOUBLE
LPWORD WORD
9
A.) EN_DATA_STREAM
This Enumerated data type may be used to identify a specific data stream
where required. The defined elements for this data type are as follows:
The element “dataDefault” refers to the data stream for which the calling analysis
technique is applied. All others refer to the specific data stream requested by the
identifier.
B.) enDataType
This enumerated data type is used to identify the native data type of the object
specified. The return value of the DataType property for some of the interface
objects described below will return a value in this data type’s range. The defined
elements for this data type are as follows:
Identifier Value
dtUnknown 1
dtBoolean 2
dtTrueFalse 2
dtString 3
dtInteger 4
dtInt64 5
dtFloat 6
dtDouble 7
dtPointer 11
C.) enPlatformType
10
This enumerated data type has been implemented for future use. It’s purpose
is to identify the platform type of the application running the analysis, specifically
from the PlatformType property of the ITradeStationPlatform interface described
below. The defined elements for this type are as follows:
Identifier Value
ptUnknown -1
ptDesktop 0
ptServer 1
4.) Structures
A.) TSRuntimeErrorItem
This defined data structure is used when registering a custom runtime error
item in the user DLL. It is composed of the following items:
sLongString – A BSTR variable which stores the string that appears in the details
section of the TradeStation Events Window, when the specific TSRuntimeErrorItem is
highlighted in the Event Window’s main list.
sShortString – A BSTR variable which stores the string that appears in the
TradeStation Events Window. This should be summary of the error encountered.
The following interfaces are supported and available for use with the
EasyLanguage Extension SDK Library:
11
IEasyLanguageObject
IEasyLanguageVariable
IEasyLanguagePrice
IEasyLanguageDateTime
ITradeStationPlatform
IEasyLanguageErrors
IELFrameworkArray
IEasyLanguageSystem
IEasyLanguageProperties
IEasyLanguageServerField
The following interfaces are for internal use only. These interfaces are not intended
for direct access from your DLL:
IEasyLanguageDataElement
IEasyLanguageVector
IEasyLanguageReadOnlyVector
IEasyLanguageEvent
12
A.) IEasyLanguageObject - Property Reference
Property Description Syntax Notes
Name
Close Returns Closing price for the bar requested as a InterfaceObject.Close[nBarsBack] 1
double precision decimal value.
CloseMD Returns an IEasyLanguagePrice interface object, InterfaceObject.CloseMD[enDataStream] 2, 3
which contains the close for the data stream
requested.
CurrentBar Returns CurrentBar value associated with the parent InterfaceObject.CurrentBar[enDataStream] 3
analysis technique to the interface object, as an
integer.
DataStream Returns the data stream of the interface object as an InterfaceObject.DataStream
EN_DATA_STREAM enumerated value (see the Data
Type Reference).
DateTime Returns the DateTime value of the interface object as InterfaceObject.DateTime[nBarsBack] 1, 4
a double precision decimal value.
DateTimeMD Returns an IEasyLanguageDateTime interface object, InterfaceObject.DateTimeMD[enDataStream] 2, 3
which contains the date-time information for the data
stream requested.
DownTicksMD Returns an IEasyLanguagePrice interface object, InterfaceObject.DownTicksMD[enDataStream] 2, 3
which contains the downticks for the data stream
requested.
GetServerField Returns an IEasyLanguageServerField interface InterfaceObject.GetServerField[szFieldName][enDataStream] 2, 3,
object, which contains the applicable data for the 5
server field requested.
High Returns the high for the bar requested as a double InterfaceObject.High[nBarsBack] 1
precision decimal value.
HighMD Returns an IEasyLanguagePrice interface object, InterfaceObject.HighMD[enDataStream] 2, 3
which contains the high for the data stream
requested.
Low Returns the low for the bar requested as a double InterfaceObject.Low[nBarsBack] 1
precision decimal value.
LowMD Returns an IEasyLanguagePrice interface object, InterfaceObject.LowMD[enDataStream] 3
which contains the low for the data stream
requested.
MaxBarsBack Returns the MaxBarsBack value of the parent analysis InterfaceObject.MaxBarsBack
technique to the interface object, as an integer.
13
A.) IEasyLanguageObject - Property Reference
Property Description Syntax Notes
Name
Open Returns the opening price for the bar requested as a InterfaceObject.Open[nBarsBack] 1
double precision decimal value.
OpenInt Returns the open interest for the bar requested as an InterfaceObject.OpenInt[nBarsBack] 1
integer value.
OpenIntMD Returns an IEasyLanguagePrice interface object, InterfaceObject.OpenIntMD[enDataStream] 2, 3
which contains the open interest for the data stream
requested.
OpenMD Returns an IEasyLanguagePrice interface object, InterfaceObject.OpenMD[enDataStream] 2, 3
which contains the open for the data stream
requested.
Tag This property may be used to store or retrieve any InterfaceObject.Tag ( = nValue) 6
extra data for a particular need. Example: Store
pointer to customized data type objects.
UpTicksMD Returns an IEasyLanguagePrice interface object, InterfaceObject.UpTicksMD[enDataStream] 2, 3
which contains the upticks for the data stream
requested.
Variables Returns an IEasyLanguageVariable interface object, InterfaceObject.Variables[nVar | nVarName] 2, 7
which contains data for the variable requested.
VariablesCount Returns the number of variables declared in the InterfaceObject.VariablesCount
parent analysis technique to the interface object, as
an integer.
Volume Returns the volume for the bar requested as an InterfaceObject.Volume[nBarsBack] 1
integer value.
VolumeMD Returns an IEasyLanguagePrice interface object, InterfaceObject.VolumeMD[enDataStream] 2, 3
which contains the volume for the data stream
requested.
14
IEasyLanguageObject Property Table Notes:
1.) nBarsBack - Required. An integer representing the number of bars back from the current bar for which the item is requested. This value
must be greater than or equal to zero and an integer or a runtime error will result.
2.) Please refer to properties that apply to the returned interface type (IEasyLanguagePrice, IEasyLanguageDateTime,
IEasyLanguageServerField, etc) for details on how to return the value in a specific format.
3.) enDataStream – Required. An EN_DATA_STREAM enumerated value representing the data stream for the close price requested. Please
refer to the Data Type section for details on the EN_DATA_STREAM data type.
4.) DateTime format - The whole number portion of the result is returned in standard Windows Date format (i.e. day.time). The decimal
portion of the result represents the amount of time that has transpired for the current day. For example, the return value for the DateTime
property on the 12:00:00pm bar of 10/24/2005 is 38649.50000.
5.) szFieldName - Required. A string value representing the server field requested. The name requested should be sent exactly as it
appears in the elf_info.txt file. Also, the data returned from this property will be the value as of the moment that EasyLanguage calculates the
study and calls the function containing this property. Your EasyLanguage study will NOT update when the requested server field updates,
unless the EasyLanguage code itself refers to the specified server field.
6.) nValue - Required. Stores an integer value for user storage of custom data. May be used to store pointers to user-defined objects.
7.) nVar | nVarName – One or the other is required. Do not use both. nVar is an integer value representing the enumerated value of the
variable requested. If used, nVarName is not used. nVarName is a string value representing the name of the variable requested. Proper
case for the variable name is not required. If nVarName is used, nVar is not used.
15
B.) IEasyLanguagePrice - Property Reference
16
IEasyLanguagePrice Property Table Notes:
1.) nBarsBack - Required. An integer representing the number of bars back from the current bar for which the item is requested. This value
must be greater than or equal to zero and an integer or a runtime error will result.
2.) DateTime format - The whole number portion of the result is returned in standard Windows Date format (i.e. day.time). The decimal
portion of the result represents the amount of time that has transpired for the current day. For example, the return value for the DateTime
property on the 12:00:00pm bar of 10/24/2005 is 38649.50000.
3.) Boolean values – Named for George Boole, these values are considered “False” if equal to zero, and “True” if non-zero.
17
C.) IEasyLanguageVariable - Property Reference
18
C.) IEasyLanguageVariable - Property Reference
19
IEasyLanguageVariable Property Table Notes:
1.) nBarsBack - Required. An integer representing the number of bars back from the current bar for which the item is requested. This value
must be greater than or equal to zero and an integer or a runtime error will result.
2.) dValue - Optional. A double precision floating point value to be assigned to InterfaceObject.
3.) nValue - Optional. An integer value assigned to the property being assigned. Non-integer values will be truncated to an integer. When
assigned to the SelectedIndex[nDimension] property, this value must not exceed the value of the property DimensionSize for the selected
dimension.
5.) bValue – Optional. Boolean value. Named for George Boole, these values are considered “False” if equal to zero, and “True” if non-zero.
6.) nDimension – Required. Specifies the array dimension to be used. This value must not exceed the value of the property Dimensions –
1, or an array bounds runtime error will occur.
7.) IEasyLanguagePrice interface objects, like IEasyLanguageVariable interface objects, support this property. However, price data values in
EasyLanguage are always series values. So they will always return 1. Therefore, this property is unnecessary for IEasyLanguagePrice
interface objects. This property has been purposefully omitted from the IEasyLanguagePrice property reference, above.
8.) The SelectedIndex property must be set for every dimension of the array before any attempts to access individual array elements can be
made.
10.) DateTime format - The whole number portion of the result is returned in standard Windows Date format (i.e. day.time). The decimal
portion of the result represents the amount of time that has transpired for the current day. For example, the return value for the DateTime
property on the 12:00:00pm bar of 10/24/2005 is 38649.50000.
20
D.) IEasyLanguageDateTime - Property Reference
21
IEasyLanguageDateTime Property Table Notes:
1.) nBarsBack - Required. An integer representing the number of bars back from the current bar for which the item is requested. This value
must be greater than or equal to zero and an integer or a runtime error will result.
2.) DateTime format - The whole number portion of the result is returned in standard Windows Date format (i.e. day.time). The decimal
portion of the result represents the amount of time that has transpired for the current day. For example, the return value for the DateTime
property on the 12:00:00pm bar of 10/24/2005 is 38649.50000.
22
E.) ITradeStationPlatform - Property Reference
23
F.) IEasyLanguageErrors - Property Reference
24
IEasyLanguageErrors Property Table Notes:
1.) errID - Required. An integer value which represents an error code defined by the developer for the error being generated.
2.) errItem - Required. A TSRuntimeErrorItem object representing the custom runtime error being registered to the user DLL. Please see the
Data Types section for details on this data structure.
25
G.) IELFrameworkArray - Property Reference
26
Property Description Syntax Notes
Name
Resize This method resizes an array to the specified length. If the InterfaceObject.Resize(nHandle, nNewSize); 6,9
new size is smaller than the old one, the extra elements are
truncated from the array. If the new size is larger than the
existing array, the new elements are assigned the initialized
value that was originally assigned to the array.
SetFloatValue This property assigns the floating-point value passed to the InterfaceObject.SetFloatValue(nHandle, nIndex, 6,7,10
specified array index. fValue)
SetIntegerValue This property assigns the integer equivalent of the value InterfaceObject.SetIntegerValue(nHandle, nIndex, 6,7,8
passed to the specified array index. nValue)
SetValue This method sets the value of the specified index, for the InterfaceObject.SetValue(nHandle, nIndex, vValue) 6,7,11
dynamic array handle passed into it. The value will internally
format, according to the datatype that was declared or
detected for the dynamic array.
SetValueRange This method sets the value of the specified index range, for InterfaceObject.SetValue(nHandle, nBegin, nEnd, 6,11
the dynamic array handle passed into it. The value will vValue)
internally format, according to the data type that was
declared or detected for the dynamic array.
Sort This method will sort the values in the specified index range, InterfaceObject.Sort(nHandle, nBegin, nEnd, 6
for the dynamic array handle passed into it. The value will bAscending)
sort in Ascending, or Descending order, depending on the
Ascending value passed to it.
Sum This method returns the sum of the values within the InterfaceObject.Sum(nHandle, nBegin, nEnd) 6
specified data range. Values are returned as a double-
precision floating point value.
27
IELFrameworkArray Property Table Notes:
3.) nSourceIndex - Required. An integer that identifies the index to begin the comparison from for the first array.
4.) nDestIndex - Required. An integer that identifies the index to begin the comparison from for the second array.
5.) nCount - Required. An Integer that identifies the number of elements to perform the comparison upon.
7.) nIndex – Required. An integer that identifies the array element requested.
8.) nValue – Required. The Integer value that will be assigned to the array element specified.
9.) nNewSize – Required. The An Integer representing the new size of the array.
10.) fValue – Required. The value that will be assigned to the array element specified.
11.) vValue – Required. A variant that will be used to set the new value of the specified array index.
28
H.) IEasyLanguageSystem - Property Reference
29
I.) IEasyLanguageProperties - Property Reference
30
IEasyLanguageProperties Property Table Notes:
1.) General: This interface is a collection of properties in the format: field = value. Field can be a string or an integer. Value is always a
Variant. This property is made available for developer storage of data of any type - an integer, a double, a pointer to an object, an interface,
etc. The Items property can be considered to be an expanded version of the Tag property of the IEasyLanguageObject interface, described
above. The Tag property allows the developer to store a single item. However, the IEasyLanguageProperties Items property allows for
developer storage of multiple items. The Items property can be used to store per-instance or per-program data.
2.) When large amounts of data are being stored, the ItemsByInteger property is preferred to the Items property for best computational
speed performance. This is because ItemsByInteger can be accessed without using the slower string operations that Items requires.
31
J.) EasyLanguageServerField - Property Reference
32
Property Description Syntax Notes
Name
Max This property returns the largest value in the interface object’s InterfaceObject.Max;
data series up to the current calculation point. The value is
returned as a double precision floating point number.
Min This property returns the smallest value in the interface InterfaceObject.Min;
object’s data series up to the current calculation point. The
value is returned as a double precision floating point number.
Name This property returns the case sensitive name assigned to the InterfaceObject.Name;
interface object as declared in the EasyLanguage code. The
value is returned as a BSTR.
Size This property returns the native size, in bytes, of the interface InterfaceObject.Size;
object. The value is returned as an integer.
Value This property returns the value stored in the interface object. InterfaceObject.Value[nBarsBack]; 1
NOTE: The return type of this property is a VARIANT;
therefore, the actual value returned is dependant on the type
of the receiving variable.
33
IEasyLanguageServerField Property Table Notes:
1.) nBarsBack - Required. An integer representing the number of bars back from the current bar for which the item is requested. NOTE: This
value must be a positive integer or a runtime error will result. Please see technical notes for details
34
Demonstration DLL Code
//////////////////////////////////////////////////////////////
// Calculate simple moving average value
// verify that sufficient bars have passed before back-referencing historical prices
if( pELObj->CloseMD[data1]->BarsBack > iAvgLength && iAvgLength > 0 )
{
double dSum = 0.0 ;
for (int i = 0; i < iAvgLength; i++)
{
dSum += pELObj->CloseMD[data1]->AsDouble[ i ] ;
}
dMovAvg = dSum / iAvgLength ;
}
return dMovAvg ;
}
//////////////////////////////////////////////////////////////
// Generate a run-time error in TradeStation
// This function is called internally by other DLL functions when an error in TradeStation
// is to be produced.
void fnGenRunTimeError
( IEasyLanguageObject * pEL, int iErrorNum )
35
{
TSRuntimeErrorItem tsItem;
int m_HistErr ;
tsItem.sCompany = _bstr_t("TradeStation Securities, Inc.").copy();
tsItem.sErrorLocation = _bstr_t("Example Code Library").copy();
tsItem.sErrorCategory = _bstr_t("Error").copy();
tsItem.sLongString = NULL;
tsItem.nParameters = 0;
switch ( iErrorNum )
{
case 1:
{
// Error 1
tsItem.sShortString = _bstr_t("Error – Description of Error 1 goes here.").copy();
tsItem.sSourceString = _bstr_t("Additional detailed description goes here.").copy();
tsItem.nErrorCode = iErrorNum ;
}
break ;
case 2:
{
// Error 2
tsItem.sShortString = _bstr_t("Error – Description of Error 2 goes here.").copy();
tsItem.sSourceString = _bstr_t("Additional detailed description goes here.").copy();
tsItem.nErrorCode = iErrorNum ;
}
break ;
default:
{
// Generate a run-time error of undefined type or origin
tsItem.sShortString = _bstr_t("Undefined error in "
"MyDLL.dll.").copy();
tsItem.sSourceString = _bstr_t("Error origin undefined.").copy();
tsItem.nErrorCode = 9999 ;
}
}
36
pEL->Errors->RaiseRuntimeError( m_HistErr ) ;
}
//////////////////////////////////////////////////////////////
// Server field call
double __stdcall GETSERVERFIELD
(IEasyLanguageObject *pEL, LPSTR szFName)
{
IEasyLanguageServerField *iSF = pEL->ServerField[_bstr_t(szFName)][dataDefault];
return iSF->AsDouble[0];
}
//////////////////////////////////////////////////////////////
// Sort an EasyLanguage array using this DLL function
37
pELVar->SelectedIndex[0] = nInner ;
pELVar->Value[0] = dTmp ;
}
}
}
}
}
//////////////////////////////////////////////////////////////
// Fill dynamic EasyLanguage array
38
//////////////////////////////////////////////////////////////
// Sum upticks and downticks from intraday chart to get volume in DLL – store in global DLL variable
39
Support
For support with the use of the EasyLanguage Extension SDK, please visit the Support
Center at TradeStation.com. In the TradeStation & EasyLanguage Support area of the
Support Center there is a support area specifically dedicated to the use of TradeStation-
compatible DLL’s in conjunction with EasyLanguage. Additional code examples are
available in this area of the Support Center.
https://www.tradestation.com/Discussions/forum.aspx?Forum_ID=213&selCategory=18
53&subCategory=EasyLanguage-DLL&selType=551&selVersion=0
If you have TradeStation-related DLL questions, please create a new topic in the above-
linked area of the Support Center. Click on the link labeled “New Topic” at the top of
that web page. This will take you to the “New Topic” form. When completing the form,
choose as the “Category” for your topic “EasyLanguage”. As the sub-category for your
question, choose “EasyLanguage-DLL”.
40