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

Re: EZLanguage Q



PureBytes Links

Trading Reference Links

> Value1=Lowest(Low,NPeriods);
> functionname=Average(Close - Value1,NPeriods);
> 
> If I left out the "- Value1" in the average
> functions' passed parameters I would get the
> average of the close over NPeriods number of bars
> of data in my chart, no doubt about it. When I
> pass the difference will the Value1 also look
> back over that many bars or will I get instances
> of Close[bar number] - a static value of value1?

You would pass the current value of Close *and* Value1 to the 
Average function.  Average would use the average of its last 
NPeriods inputs.  It doesn't know or care how they were computed.  
So you will get the average of Close-Value1 for each of the last 
NPeriods bars, using each bar's value of Close and Value1.

Here's a way to prove it to yourself:  The average of a constant 
is the constant itself.  I.e. Average(10, NPeriods) = 10.  Also, 
Average(X - Y, N) = Average(X, N) - Average(Y, N).  OK so far?

So Average(Close - Value1, Nperiods) is equivalent to 
Average(Close, NPeriods) - Average(Value1, NPeriods).

If TS used the current-bar value of Value1 in computing the 
average value, then you'd effectively be passing a constant value 
of "Value1" to the average.  If so, then

  Average(Close, NPeriods) - Average(Value1, NPeriods)

would be equivalent to

  Average(Close, NPeriods) - Value1

Try charting both values with a changing Value1 and you'll see 
they are NOT the same.  That's because Value1 isn't a constant; 
it's changing on every bar, and Average uses that changing value.

Gary