Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 7
|
I am trying to remove the PREV function to speed up its execution. Has anybody got any ideas?
pds:=Input("number
of periods",1,400,5); x:=2/(pds+1); xl:=LastValue((1/x)-1);
(x*((2*C)-Ref(C,-xl))) +((1-x)*PREV)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
When posting code, please use the proper code tags to differentiate it from text.
Look closely at the final expression to see it's nothing more than a 'pds' EMA of '(2*C)-Ref(C,-xl))' so use this instead.
You can also simplify the computation of the 'xl' variable, if you're really concerned about computation speed then avoid getting any program to more computations than absolutely necessary.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 7
|
Hi, WABBIT. I'm not very good at programming. That's what I did. I'll understand correctly? pds:=Input("number of periods",1,400,5); x:=2/(pds+1); xl:=LastValue((1/x)-1); Mov((x*((2*C)-Ref(C,-xl))),pds,E)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
That code is ok.
I still think you should investigate the xl variable, as it will also show you about the selection of your pds variable length. It's nothing to do with programming, just basic maths.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 7
|
Thanks a lot. I am very grateful to you! I'll check again this variable.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi K Change your formula from... Code:
pds:=Input("number of periods",1,400,5);
x:=2/(pds+1);
xl:=LastValue((1/x)-1);
x*(2*C-Ref(C,-xl)) + (1-x)*PREV
to... Code:
pds:=Input("number of periods",1,400,5);
x:=2/(pds+1);
xl:=(1/x)-1;
Mov(2*C-Ref(C,-xl),pds,E);
That works for me. I only hope the code tags are just as effective. Roy
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.