PureBytes Links
Trading Reference Links
|
At 10:23 AM -0400 5/4/99, William R Wood wrote:
>But I can;t figure out how to see the internal math of
>functions/indicators etc. For example how do you see the changing states
>of conditions that switch from true to false or the results of
>calculations by functions that contribute to the final result but do not
>get plotted. All I see so far are the final results that get plotted and
>are thus visible in the Data Window (I am using TS2k). But to understand
>how this stuff works or to debug procedures that don;t work I would like
>to see the step by step execution of the code. Sort of like how Excel lets
>you step through macro code and separately see the result of each
>component calculation. Is there anyway to do this in EL.
It is true that TradeStation has debugging features reminiscent of the
1950's but there is a way to use the "Expert Commentary" feature for this
purpose. (I originally saw this idea in the TSExpress Newsletter and have
extended it somewhat.)
The Expert Commentary is what you get when you click on the icon that
contains the "arrow and the E" in TradeStation and then click on any bar of
your price chart.
The code below, (and the attach ELA file,) contains code to illustrate this
feature. (The code is cut and pasted out of something and does nothing
useful. I just am using it as an example of this feature.)
Apply this indicator to any price chart with the plots set to plot points
on subgraph 1. It should find some points to plot in most price charts.
Then click your pointer on the Expert Commentary icon, then click on any
bar of the price chart. The Expert Commentary window should open and show
the values of all variables at that bar. Click on some other bar and it
will change to the values for that bar.
You can resize the commentary window to just include the list of variables
to minimize the space it requires. It is better to try this with no other
studies applied so that you will not get text from other studies that
include such commentary.
While it requires some effort to list all the variables you want to trace,
it is a lot better than simply printing everything to the Print Log. I find
this very useful for tracing complicated logic on a bar-by-bar basis.
Hope you find this useful.
Bob Fulks
{ *******************************************************************
Indicator: _Debug Example
Last Edit: 5/4/99
Coded By: Bob Fulks
Description: Illustrates the use of the Expert Commentary
feature for debugging - the code is nonsense.
********************************************************************}
Input: X(20); {Bars back to search for highs in H1}
Vars: H1A(FALSE), {Possible H1}
H2A(FALSE), {Possible H2}
AVal(Close), {Displaced average}
LDif(0), {Distance between Low and AVal}
H1(0), {Value of H1 high}
H2(0), {Value of H2 high}
HBB(0), {High Bollinger Band value}
uB1(0), {Upper BB value at H1}
uB2(0), {Upper BB value at H2}
Displace(3), {Displacement of moving average}
Count(0); {Bars since an H2}
if CurrentBar <= Displace then
AVal = Close
else
AVal = Average(Close,3)[Displace]; {Displaced moving average}
LDif = Low - AVal; {Distance between Low and AVal}
HBB = BollingerBand(Close, 9, 2);
Count = Count + 1;
H1A = High > Highest(High, X)[1];
H2A = Lowest(LDif, 7)[1] > 0;
Condition1 = High > HBB;
if Condition1 then begin
uB1 = HBB; {Remember Bollinger band value}
uB2 = 0; {Reset uB2}
H1 = High; {Remember High}
H2 = 0; {Reset H2}
Count = 0; {Reset Index to 0 to count bars since H1}
end;
if H1A then Plot1(High, "1");
if H2A then Plot2(High, "2");
{Commentary to show debug data}
Vars: SH1A(""), {String for H1A value}
SH2A(""), {String for H2A value}
SCo1(""), {String for Condition1 value}
String1(""); {Output string}
#BeginCmtryOrAlert
if AtCommentaryBar then begin
if H1A then SH1A = "TRUE" else SH1A = "FALSE";
if H2A then SH2A = "TRUE" else SH2A = "FALSE";
if Condition1 then SCo1 = "TRUE" else SCo1 = "FALSE";
String1 = "Values: " +
newline + " Date = " + NumToStr(Date, 0) +
newline + " Time = " + NumToStr(Time, 0) +
newline + " Count = " + NumToStr(Count, 0) +
newline + " H1A = " + SH1A +
newline + " H2A = " + SH2A +
newline + " Cond1 = " + Sco1 +
newline + " H1 = " + NumToStr(H1, 2) +
newline + " H2 = " + NumToStr(H2, 2) +
newline + " uB1 = " + NumToStr(uB1, 2) +
newline + " uB2 = " + NumToStr(uB2, 2);
Commentary(String1);
end;
#end;
Attachment Converted: "c:\eudora\attach\DEBUG.ELA"
|