Double check your code to ensure that it follows the pattern given. Note that I 
used a *condition* in the Sum function, which will evaluate to 1 (true) or zero 
(false). Summing those up for the last 5 days will give the number of times the 
condition was true over that period.

In this mail you said MACD below 0, in your previous one you said above 0. 
Whichever it is you want, enter the condition as the first argument to the Sum 
function.

Buy = Sum(MACD < 0, 5) == 5;

Mike

--- In [email protected], "Rick" <ric...@...> wrote:
>
> Thanks for the help.  I attempted to use the suggested "sum" but it adds the 
> days together as a calculation (sum of last 5 days for the array).
> 
> What I really want is to find that a condition existed for the last 5 days 
> (i.e MACD was below 0 for each of the last 5 days).
> 
> I browsed thru the AFL's - should I use a nested IIF statement?
> 
> Thx!
> 
> --- In [email protected], "Mike" <sfclimbers@> wrote:
> >
> > Sum() will do the job. But, Cross is not the right operator to use. Cross 
> > is only true on the bar of the actual cross. You stated that you wanted to 
> > verify that the indicator was above 0 for all the days of the period. 
> > Therefore, just use the ">" operator within the Sum function.
> > 
> > MyCalculation = ...;
> > Buy = Sum(MyCalculation > 0, 5) == 5;
> > 
> > To add a second condition, you will need to use an AND. You can break the 
> > logic up into as many statements as you like. But, in the end the Buy will 
> > be "x AND y" if both conditions are required to be true.
> > 
> > Mike
> >
>


Reply via email to