PureBytes Links
Trading Reference Links
|
A minor correction. I said:
"the function will return a positive number on bars 300, 301, and 302"
To be exact, it will obviously return a zero on bar 300, (which not a
positive number).
You may need to use:
if MRO(Condition1, 3, 1) >= 0 and Condition2 then Buy....;
if you want to include bar 300 in your selection.
Bob Fulks
At 3:10 PM -0500 1/2/98, Bob Fulks wrote:
>> Bob Fulks wrote:
>>
>> > Condition1 = Average(Close, 9) < Average(Close, 18);
>> >
>> > if Condition1 and ...other... then Sell...;
>>
>> This doesn't quite capture what I'm looking for, though. I'd like to
>>generate
>> signals when Condition1, Condition2, etc. have all obtained, then buy...
>>
>> The problem with the above statements is that it won't generate a signal in
>> situations where Condition2 hits, and Condition1 obtains a few bars
>>later, for
>> example.
>>
>> Thanks,
>> A.J.
>
>In the code below:
>
> Condition1 = Average(Close, 9) < Average(Close, 18);
> Condition2 = ....other.....;
>
>Condition1 and Condition2 are evaluated on every bar. The statement:
>
> if Condition1 and Condition2 then Buy ....;
>
>will buy when both conditions are true on the same bar. If Condition1
>becomes true on bar 300 and stays true, and then Condition2 becomes true on
>bar 304, then the Buy command will be executed on bar 304.
>
>On the other hand, if what you want is to buy on Condition2 if Condition1
>has been true anytime within the last, say, 3 bars you could say:
>
> if (Condition1 or Condition1[1] or Condition1[2]) and Condition2 then
>Buy ....;
>
>or, more elegantly:
>
> if MRO(Condition1, 3, 1) > 0 and Condition2 then Buy....;
>
>This will buy if Condition1 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 positive number on bars 300, 301, and 302.
>
>If Condition2 then becomes true on bar 302, the Buy signal will occur on
>bar 302 since all conditions are then satisfied.
>
>Bob Fulks
>
>
>
>
>--
>Bob Fulks
>bfulks@xxxxxxxxxxx
--
Bob Fulks
bfulks@xxxxxxxxxxx
|