PureBytes Links
Trading Reference Links
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Den 2006-02-24 19.04.04 skrev DH:
> 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
i've been looking at TS and EL for about a week, so i'm quite
aware that i don't know how it works, and that's why i'm trying
to figure it out.
okey, it's no recurisve calls, but i surely is iterative calls?
let's say we apply XAverage on a chart, with Length = 35.
Factor = (1 / Length+1 ) = 1/36
CurrentBar = 1, Price = 200
XAverage = 200
CurrentBar = 2, Price = 201
XAverage = 1/36 * 201 + (1-(1/36)) * 200 = 200,027777778
CurrentBar = 3, Price = 204
XAverage = 1/36 * 204 + (1-(1/36)) * 200,027777778 = 200,138117284
etc.
correct?
what i don't get, is when i'm calling the function in EL-code and
appends the value to a file, i mean, if it works as i've interpret
what you say, it's using all the bars in the chart?
at first i thought it was using Length to limit the numbers of bars
it's using in the calculation.
sorry if i'm giving you the impression of beeing thick headed.
i do appreciate you trying to help me clearing it out :)
- --
.-.-.-..---..----..---. Mikael Göransson
| | | || |'_| || || |-< http://www.mgor.se
`-'-'-'`-'-/`----'`-'`-' micke@xxxxxxx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFEAc8TVBSPWpaZs/0RAiBaAKCB+GEEHRZPoOa+7GoAa4oBmN7sDQCfVeM3
wTAJFX7/yoTbo+yzxwnBon4=
=d6Jl
-----END PGP SIGNATURE-----
|