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

Re: Need EL Help



PureBytes Links

Trading Reference Links

At 6:00 PM -0400 1/2/98, A.J. Carisse wrote:

<SNIP>

>Thanks for the help, Bob. Here's the problem I'm having. If Condition2
>while Condition1, then no problem. However, I'm not getting signals if
>Condition2 precedes Condition1 with the particular system I'm trying to
>write. The problem seems to arise from the fact that one of the conditions
>is based upon a reversal - in this case, MACD. If I knew how to rewrite
>this indicator so that, for instance, the condition would always be true
>if the fast MACD was above the slow MACD, then I think this would solve
>the problem in this particular case. I'm sure there is a simple way to do
>this, but I'm just learning EL, and I'd appreciate it if you could give me
>a hand.

I believe the solution I posted addresses this case precisely. (Corrected
version using your terminology is repeated below):

Modified Quote:

<<< On the other hand, if what you want is to buy on Condition1 if
Condition2 has been true anytime within the last, say, 3 bars you could say:

   if (Condition2 or Condition2[1] or Condition2[2]) and Condition1 then
        Buy ....;

or, more elegantly:

   if MRO(Condition2, 3, 1) >= 0 and Condition1 then Buy....;

This will buy if Condition2 becomes true on bar 300 and then goes false.
Since the Most Recent Occurance function (MRO) specifies a 3 bar lookback,
the function will return a non-negative number on bars 300, 301, and 302.

If Condition1 then becomes true on bar 302, the Buy signal will occur on
bar 302 since both conditions for the Buy ("MRO(Condition2, 3, 1) >= 0" and
"Condition1") are then satisfied.>>>

End modified quote.

I still don't understand exactly what you want but it seems as if the MACD
crossover is Condition2 and your subsequent condition is Condition1. You
don't have to rewrite anything. The code will buy if Condition1 occurs
within some specified number of bars, three in the example given, after
Condition2 occurs, even if Condition2 is no longer true.

The term Condition2[1] refers the state of Condition2 one bar ago.
The term Condition2[2] refers the state of Condition2 two bars ago.

so the term:

   (Condition2 or Condition2[1] or Condition2[2])

is true if Condition2 was true on this bar or was true one bar ago or was
true two bars ago. It doesn't have to be true on this bar, just sometime in
the recent history.

You can obviously extend this to any length you want or, alternately, use
the MRO function which does this for you.

The expression "MRO(Condition2, 3, 1) >= 0" refers to the "Most Recently
Used" function which you can look up in the help system.

Contact me privately (off the list) if this is still not clear.

Bob




--
Bob Fulks
bfulks@xxxxxxxxxxx