Debugging Your System
If At First You Don't Succeed
by John Clayburg
Systems you create don't always work quite right at first. And when you revise them, your "improvements" don't necessarily help. It's what you ordered ... but not what you wanted. What to do? For those who use EasyLanguage, here's the solution.
Sooner or later, those who write computer program code, whether for personal strategies or for programming for others, must face the task of correcting errors or making changes in their work. The process of finding and correcting program errors, often referred to as debugging, can be as challenging and frustrating as writing the program code itself. To effectively and efficiently make changes in program code, often you must determine values for specific variables on selected bars on a chart. Many software platforms provide multiple utilities within their frameworks specifically for this purpose.
For the purposes of this article, I'll concentrate on the processes that can be used to debug programs written on the EasyLanguage system and indicator development platform. The routines presented here are equally applicable to TradeStation 4.0, ProSuite 2000i, and the current online version, TradeStation 6.0.
DEBUGGING WITH THE PRINT STATEMENT
EasyLanguage contains within its basic structure a specific debugging routine, which comes into use when writing print statements into your program code. The print statement will deliver specific variable values to the debug window in the power editor, to a file, or to a printer.
This debugging tool is very thorough in that it sends the requested information to the designated output device for every bar on the chart on which the analysis technique is applied. To interpret these outputs, a date (and time, if testing intraday data) should be included as the first two output characters. This allows you to eventually track down the specific values of the variables for the section of the chart on which the program errors have been identified.
Although the print statement method of debugging programs is thorough, it is somewhat complicated to program and time-consuming to decipher. Each variable output must be individually formatted for proper calculation. Most often, you are only concerned with a few bars on the chart where you have observed errors. You must observe the actual values being calculated by the code to make the necessary corrections. Since each bar on the chart in question results in a new line of output data, sifting through the data in search of the specific bar on which the error is evident can be a lengthy, error-prone process.
FIGURE 1: System setup. This system considers two stochastic values and a support level.
...Continued in the March 2002 issue of Technical Analysis of STOCKS & COMMODITIES
John Clayburg has been involved in trading and systems development for more than 20 years. He also offers custom programming services for TradeStation users. He may be reached at email@example.com or www.clayburg.com.
Excerpted from an article originally published in the March 2002 issue of Technical Analysis of STOCKS & COMMODITIES magazine. All rights reserved. © Copyright 2002, Technical Analysis, Inc.
Return to March 2002 Contents