PureBytes Links
Trading Reference Links
|
Thanks to Pierre Orphelin, Don ("countachl"), Gary Fritz and Wayne
Mathews (who replied via private e-m) for the replies.
I had neglected to mention that taking the average was just an
example - there would be other operations I'd want to do on the
variable.
While I'd prefer that there was an element of EasyLanguage knowledge
which I was missing, I am glad to see confirmed what I had concluded
- that the only 'real' soln via EasyLanguage (assuming I didn't want
to discard price values prior to CurrentBar=1) was to use an array.
I think Don summed it up best when he noted that TS doesn't
assumulate 'derivative' variables during the MBB period. If the
syntax allowed it this would do the trick:
for cntr = 1 to MaxBarsBack begin
myVar[i] = C[i];
end;
Some specific replies to comments received:
> Who cares about the first 40 bars anyway? Just make your chart
> longer and don't pay attention to the first bit.
I found it using a weekly chart w/10 years of data and doing a 100
len calculation. I had thought of the suggestion of just making the
chart longer and ignoring the first bit but it offended my (perhaps
oversensitive :-) ) sense of elegance to have to throw away two years
of data. Since I generally think the Universe is elegant I thought I
must be missing something. :-) It appears I'm not :-(.
> Set maxbarsback to 20, then currentbar = 1 will start at bar 21.
> This is the reason why mbback exists.
> You cannot initialize a 20 bars moving avaerage with less than 20 bars...
Yes, but at CurrentBar=1 20 bars does exist in Close e.g.
Close[1]...Close[20]. I wanted to get that into myVar[1]...myVar[20].
Regards,
Brendan
> Hello,
>
> Suppose I want to average C e.g. value1 = Average(C, 20). With
> CurrentBar = 1 this works as I expect.
>
> Suppose instead I want to copy C into a variable and average that e.g.
>
> Value1 = C;
> value2 = Average(Value1, 20);
>
> (The reason I want to do this is to compute an average on a
> transformation of C).
>
> The problem is that this won't produce the results I expect until
> CurrentBar = 20 because (using CurrentBar = 1 as reference) Value[20]
> through Value[1] aren't initialized with C[20] through C[1] but
> instead 0.
>
> Does anyone have thoughts on how I can initialize these portions of
> Value1?
>
> Thanks in advance.
>
> Regards,
> Brendan
>
|