PureBytes Links
Trading Reference Links
|
Jody, try something like this:
Variables: UpCount(0), DownCount(0), I(0);
UpCount = 0; DownCount = 0;
For I = 0 to 9 begin
if C[I] > C[I+1] then UpCount = UpCount + 1 else
if C[I] < C[I+1] then DownCount = DownCount + 1;
end;
This will give you, for each bar, the number of Up bars within the last 10 bars in
UpCount, and the number of Down bars within the last 10 bars in DownCount.
Note that EL has an implicit "For" loop - the code is run once for every bar. So if
all you want is a counter that increases with each up bar and decreases with each
down bar, then all you need is
vars: Count(0);
if C > C[1] then Count = Count + 1 else
if C < C[1] then Count = Count - 1;
> -----Original Message-----
> From: Jody Ellis [mailto:ellis_jody@xxxxxxxxxxx]
> Sent: Tuesday, August 21, 2001 4:42 AM
> To: omega-list@xxxxxxxxxx
> Subject: Loop Statements
>
>
>
> Hello,
>
> I am trying to create a loop statement to count how many up days and how
> many down days for a specified look back period. For example, I wish to
> create a counter called "count" that will add and/or subtract 1 each time
> the market closes above/below previous close. I have tried the following but
> need some help;
>
> Variables: count(0);
>
> For 1 = 10 Begin
> If C > C[1] Then Count = Count + 1;
> If C < C[1] Then Count = Count – 1 ;
> End;
>
> This doesn’t work, as I don’t have much of an idea how these statements
> work. Can somebody please help me understand the fundamentals of these
> statements? Thanks.
>
> Jodie.
>
>
>
>
|