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

Re: EasyLanguage Questions



PureBytes Links

Trading Reference Links

>Something Bob Fulks wrote just gave me a thought.
>
>> You can refer to the values of each data series with an index.
>> For example, if you wanted to add all the closes of 30 data streams you
>> could say:
>>
>>   MySum = 0;
>>   for j = 1 to 30 begin
>>      MySum = MySum + Close of data(j);
>>   end;
>
>What happens if you do something like this?
>
>    for j = 1 to 10 begin
>       s[j] = xAverage(close data(j), length);
>    end;
>
>I recall a function occuring in the same spot will retain its internal
>variable values within the function from one bar to the next.  And here
>it's being called several times in the same spot.  Each time xAverage is
>called in the loop, does it retain its local variable values from the
>previous loop?  You wouldn't want that to happen in this case.

I've learned it's advisable to take the data(j) outside and write the above as:

    for j = 1 to 10 begin
       s[j] = xAverage(close, length) of data(j);
    end;

Maybe it's because the compiler keeps a separate instance for each data stream when you do it this way, and avoids the problem you refer to.

Mike Gossland