PureBytes Links
Trading Reference Links
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hello,
i'm trying to create my own XAverge function in a diffrent language
then EL. to evaluate the calculations i'm using output from
tradestation as reference.
XAverage EL code:
Inputs: Price(NumericSeries), Length(NumericSimple);
Variables: Factor(0)
If Length + 1 <> 0 Then Begin
If CurrentBar <= 1 Then Begin
Factor = 2 / (Length + 1);
XAverage = Price;
End
Else
XAverage = Factor * Price + (1 - Factor) * XAverage[1];
End;
i don't quite know what CurrentBar is, does it start with today, so
when CurrentBar = 1 it's today, and if Length is 35, the last
CurrentBar would be 35?
the above code is using recursion, so the first call (CurrentBar = 1)
would return todays price? and the second call would return XAverage[1]
be todays price?
i've got my close values in an array, let's say 35 values, and i start
the couting at 0, so the last price in the array would be at index 34.
instead of recursion i've used iteration, and this is how i've done it
(in pseudo-code), and it dosen't return the same value as the EL code.
price = array( 24, 24.5, 24.3, ...)
length = 35
factor = 2 / (length plus 1)
for i, i less then length, increase i
if i is bigger then 0
xaverage = factor times price[i] plus (1 minus factor)
times xaverage
else
xaverage = price[i]
done
return xaverage
i must be missing something since it's not giving the same result, i've
tried diffrent solutions, but iterative and recrusive, and almost every
time i've ended up with the same result as the above solution.
any help would be great, i'm going nuts.
cheers.
- --
.-.-.-..---..----..---. Mikael Göransson
| | | || |'_| || || |-< http://www.mgor.se
`-'-'-'`-'-/`----'`-'`-' micke@xxxxxxx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFD+0q1VBSPWpaZs/0RAhONAJ4gK3StAHLdGkRDkNDk1beWrGVSNwCgk+tH
0VH3gsw3txCG7pvWDU0z1zw=
=tubS
-----END PGP SIGNATURE-----
|