[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Obscure EasyLanguage Bug



PureBytes Links

Trading Reference Links

This post describes a fairly obscure EasyLanguage issue that I would think
might affect many people. It relates to how functions are evaluated. I have
not seen the problem described before.

A few days ago I posted the problem to this list and to Omega's
EasyLanguage Support group. Omega replied the next day to explain the
source of the error and said they would refer it to Product Development.
Today, I received a message from Product Development saying they would try
to fix it in the next release.

It is fairly well known that many functions, such as series functions, need
to be evaluated on every bar to return the correct values. Such functions
should not be included in conditional expressions such as:

       if <condition> then <function>;

that would prevent them from being evaluated on every bar.


But the case I discovered fails to evaluate the function in an expression
that would appear to be evaluated on every bar, but isn't.

I included these functions in a complex expression that is executed on
every bar:

     Condition1 = HighW(1) > HighW(2) and LowW(1) < LowW(2) and
        CloseW(1) > HighW(2);

The functions HighW, LowW, and CloseW are of the type that needs to be
evaluated on every bar.

But, in fact, the functions are not evaluated on every bar in this
expression. It turns out that if the result of the first (or second)
comparison:

     HighW(1) > HighW(2)

is false, then the terms that follow are not executed. (If any term is
false, the overall expression is obviously false). This is usually done to
speed up program execution by saving unnecessary calculations.

Thus, the functions further on in the expression are NOT EVALUATED on that
bar and will then give incorrect values on future bars.

The workaround is to break up the expression into smaller parts that will
assure that all of the functions will be evaluated on every bar even if any
of the comparisons are false.

   Condition2 = HighW(1) > HighW(2);
   Condition3 = LowW(1)  < LowW(2);
   Condition4 = CloseW(1) > HighW(2);
   Condition5 = Condition2 and Condition3 and Condition4;

The response from Product Development said to break the expressions down
into even smaller parts:

   Value4 = HighW(1);
   Value5 = HighW(2);
   Condition6 = Value4 > Value5;
   Value6 = LowW(1);
   Value7 = LowW(2);
   Condition7 = Value6 < Value7;
   Value8 = CloseW(1);
   Value9 = HighW(2);
   Condition8 = Value8 > Value9;
   Condition9 = Condition6 and Condition7 and Condition8;

But I don't see why this is necessary. Both gave the same result in my
testing. Perhaps someone can see a reason.

My original post and the responses from Omega are attached below in case
you would like to see the details.

I would like to thank Omega for the prompt and complete analysis.

Bob Fulks

---------------
Date: Sun, 8 Mar 1998 12:46:42 -0500
To: omega-list@xxxxxxxxxx
From: Bob Fulks <bfulks@xxxxxxxxxxxx>
Subject: EL Problem with HighW/LowW/CloseW functions
Cc: EasyLang@xxxxxxxxxxxxxxxxx

I have what appears to be an "anomaly" in EasyLanguage.

Below is an indicator that plots four plots on daily bars.

  >Plot1 is a complex expression of the value I was looking for.
  >Plot2 is the same value split into 2 expressions.
  >Plot3 is the same value split into 5 expressions.
  >Plot4 is the same value split into 11 simplest possible expressions.

Plot3 and Plot4 are the same and presumable correct. Plot1 and Plot2 are
very different and presumable in error.

Any idea what is causing this?

(The HighW/LowW/CloseW functions on my system are all dated
"Last Update 10/10/96" and I am using TradeStation 4.0)

Thanks.

Bob Fulks

--------------


Value1 = MRO(HighW(1) > HighW(2) and LowW(1) < LowW(2) and
   CloseW(1) > HighW(2),15,1);
Plot1(Value1, "Plot1");


Condition1 = HighW(1) > HighW(2) and LowW(1) < LowW(2) and
   CloseW(1) > HighW(2);
Value2 = MRO(Condition1,15,1);
Plot2(Value2, "Plot2");


Condition2 = HighW(1) > HighW(2);
Condition3 = LowW(1)  < LowW(2);
Condition4 = CloseW(1) > HighW(2);
Condition5 = Condition2 and Condition3 and Condition4;
Value3 = MRO(Condition5,15,1);
Plot3(Value3, "Plot3");


Value4 = HighW(1);
Value5 = HighW(2);
Condition6 = Value4 > Value5;
Value6 = LowW(1);
Value7 = LowW(2);
Condition7 = Value6 < Value7;
Value8 = CloseW(1);
Value9 = HighW(2);
Condition8 = Value8 > Value9;
Condition9 = Condition6 and Condition7 and Condition8;
Value10 = MRO(Condition9,15,1);
Plot4(Value10, "Plot4");

----------------------

From: easylang@xxxxxxxxxxxxxxxxx
Date: Mon, 9 Mar 1998 16:44:25 -0500
To: bfulks@xxxxxxxxxxxx
Subject: Re:EL Problem with HighW/LowW/CloseW functions
Mime-Version: 1.0

980309AJ
Dear Mr. Fulks,

The functions must "See" every bar, some of them in plot1 and plot2 are nested
so that if the condition beside them is false then they aren't evaluated so
they
have no value for that bar. In plot3 and plot4 the functions aren't nested so
you get the correct value.

Sincerely,
Aaron Jackson
Easy Language Specialist

---------------------

From: diana.almeida@xxxxxxxxxxxxxxxxx
Date: Wed, 11 Mar 1998 16:35:26 -0500
To: bfulks@xxxxxxxxxxxx
Subject: Re:Fwd:EL Problem with HighW/LowW/CloseW functions
Mime-Version: 1.0

Mr.  Fulks,

Thank you for bringing this to our attention.  We have duplicated the problem
in-house and have forwarded it on to Product Development.  We will make our
best
efforts to have this problem corrected for the next release of our products.

As for a workaround, you have already discovered it in Plot4.  As long the same
function is not called on the same line, your results will be accurate.  For
example,

HighW(0) < HighW(1)     will yield inaccurate results.

However,

Value1 = HighW(0)
Value2 = HighW(1)
Value1 < Value2         will yield accurate results.

Please let me know if you have any questions of would like further
clarification.  Thank you again.

Regards,

Diana