PureBytes Links
Trading Reference Links
|
Sorry. I misunderstood what you were looking for. Since you seem to
want to know what percentage of the past prices are within a band
around the current price, there is no easy way except by searching
back. Something like this should work (untested):
{Find band values for this bar}
level = close;
topband = level + band / 2;
bottomband = level - band / 2;
Count = 0;
{Count number of occurrences during past Length bars)
for j = 1 to Length begin
Condition1 = Close[j] < topband and Close[j] > bottomband;
if Condition1 then Count = Count + 1;
end;
{Figure percentage}
significance = 100 * Count / Length;
Bob Fulks
--
At 4:00 PM +0100 7/8/01, Virgin Trader wrote:
>That is definitely faster but does not solve the problem.
>
>Say (just as an example) the most recent price is 100 and the preceding 5
>prices were 99,97,97,99,99.
>I want to return a value of how many times in the previous 4 bars (say) the
>price has been at 100 (setting band to zero).
>
>The answer, by inspection, is 0. However my code (and yours) will give a
>value of 2 because instead of comparing the last 4 values with 100, it does
>the following:
>
>99<>97 therfore count = 0
>97 = 97 therefore count =1
>97<>99 therfore count= 1(still)
>99=99 therefore count=2.
|