PureBytes Links
Trading Reference Links
|
> hm, so what does MXAverage[1] actually do? i thought i was a function
> call with the same parameters as the first call.
No, it's just recalling the stored value of MXAverage on the previous
bar. MXAverage[10] would recall the stored value of MXAverage from 10
bars ago. TS keeps an internal array of previous values. The size of the
array is determined by the Maxbarsback setting. If your code tries to
access a value further back than maxbarsback, you will get an internal
error.
> what i can't grasp is how many bars the function use to calculate
> the final XAverage value, all 255 dosen't seem logical.
You still don't seem to grasp the fundamental of how TS works on
historical data. It starts at the first bar of the chart, not at the
last bar. It does all the calcs on the first bar and then moves to the
next bar and does them again. It keeps that up until it gets to the last
bar. So, with your code, each calc is only using 2 bars but the calc is
repeated 255 times.
That's how it works on historical data. On realtime data, it's the same
when you first open the chart or apply the indicator. When new data
comes in realtime, it only does the calc on the new bar. It doesn't run
through all the bars each time a new bar forms realtime.
When you think about it, it would have to work that way. If it didn't
step through all the bars on historical data, you wouldn't be able to
plot an indicator for all of those bars. You would only get a single
point plotted at the end of the chart.
--
Dennis
|