Sorry Radek, but it is you that is mistaken.
If you want to compare 3 events using Sum, then you must use a lookback of 3. The lookback includes the current bar.
Run the following Plot to see the difference. My solution lines up with every 3rd lower low (green arrow). Your solution lines up with ever 2nd lower low (orange arrow).
Mike
---------------------------------------
Mike = Sum(Low < Ref(Low, -1), 3) == 3;
Radek = Sum(Low < Ref(Low, -1), 2) == 2;
Sell = Low > Ref(Low, -1);
Mike = ExRem(Mike, Sell);
Radek = ExRem(Radek, Sell);
Colors = IIF(Low < Ref(Low, -1), colorDarkRed, IIF(Low > Ref(Low, -1), colorGreen, colorDarkGrey));
Plot(Low, "Low", Colors, styleBar);
PlotShapes(Mike * shapeUpArrow, colorDarkGreen);
PlotShapes(Radek * shapeUpArrow, colorOrange);
--- In
amibroker@xxxxxxxxxxxxxxx, Radek Simcik <radek.simcik@xxx> wrote:
>
> This is not correct. If you want 3 consecutive lows you need to have a code
> like
>
> Buy = Sum(Low < Ref(Low, -1), *2*) == *2*;
>
> The comparison Low < Ref(Low, -1) counts for one lower low.
>
> Radek
>
> On Fri, Mar 13, 2009 at 7:10 AM, Mike <sfclimbers@xxx> wrote:
>
> > Buy = Sum(Low < Ref(Low, -1), 3) == 3;
> >
> > Mike
> >
> >
> > --- In
amibroker@xxxxxxxxxxxxxxx <amibroker%
40yahoogroups.com>, jim
> > fenster <normanjade@> wrote:
> > >
> > >
> > > If I wanted to buy for example when you make three lower lows. How do I
> > write this without doing it the long way? You know like Buy=
> > ref(l,-1)<ref(l,-2) etc. Im not lazy or anything. Im just trying to learn
> > the language. Whats the way to loop something like this?
> > >
> > > Thanks,
> > > Jim
> > >
> >
> >
> >
>