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

Re: Code Help!



PureBytes Links

Trading Reference Links

At 11:36 PM 2/26/2005, ericzh2003 wrote:
>Hi List,
>
>I'm coding a strategy and I need some help in coding:
>
>If within N bars, { ...} occurs more than M times, then
>buy stop Highest (High, N)
>Sell stop Lowest (Low, N)
>
>is there a built-in function similar to MRO?
>
>Appreciate any response.
>
>Regards,
>Eric

Hi Eric,


Use the built in "CountIF" function. This function counts the number of true occurences over a lookback length.

e.g., value1 = CountIF(Close > Open,24);

So you would use

if CountIF({...}, N ) > M then ...

----

If for some reason CountIF is not available then do this...

Create a function, say MyTest, with the {...} code in it. Output is 1 if {...} is true, 0 if false.

To see whether {...} occurs > M times in N bars, do this:

if N*Average(MyTest, N) > M then ...

HTH

Mike Gossland