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

Re: EL Question...



PureBytes Links

Trading Reference Links

At 1:10 PM -0800 11/16/00, Brian wrote:

>So while you can code around this problem, it's messy and I was wondering if
>someone could tell me how to get around this problem or pinpoint what I'm
>doing wrong.

You are calculating a value using each 3-minute bar on data2. That
number does not does not change on the intermediate 1-minute bars.

Your print statement is running on each of the 1-minute bars so it is
printing the same number three times. This is all working correctly
as you have coded it.

There are several ways to fix it:

You can simply execute the print statement on only the 1-minute bar
that corresponds to the 3-minute bar by several techniques such as:

    if Mod(CurrentBar, 3) = 0 then Print(......

There is some chance that the bars will get out of sync, but probably
not likely with daily data.

Alternately, you could convert your code to only use 1-minute bars by
calculating what the  high of a "synthetic" 3-minute bar would have
been:

    if Mod(CurrentBar, 3) = 0 then begin
       HHigh = Highest(High, 3);
       Value1 = Average(HHigh, 20);
       if Value1[7] > Value1[4] And Value1 < Value[4] Then Flipped = TRUE;
       Print(......);
    end;

Note that you need to refer to the correct bar of Value1 based upon
1-minute bars.

A slightly less obtuse version (which might make more sense when you
look at it again in several months) might be:

    if Mod(CurrentBar, 3) = 0 then begin
       HHigh  = Highest(High, 3);   {Find 3-bar high}
       Ave1   = Ave;                {Save last value}
       Ave    = Average(HHigh, 20); {Find new value}
       Slope1 = Slope;              {Save last Slope}
       Slope  = Ave - Ave1;         {Find new Slope}
       if Slope <= 0 and Slope1 > 0 then Flipped = TRUE;
       Print(......);
    end;

Bob Fulks


>I am taking an Average of the H of data2 with this: Value1 = Average(H of
>data2, 20);
>
>I am then checking for a flip down of the data2 average with this
>
>If Value1[2] < Value1[1] And Value1 < Value[1] Then Flipped = TRUE;