logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
klim  
#1 Posted : Tuesday, February 12, 2013 2:03:47 AM(UTC)
klim

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)

wabbit  
#2 Posted : Tuesday, February 12, 2013 3:44:23 AM(UTC)
wabbit

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]

klim  
#3 Posted : Tuesday, February 12, 2013 4:26:58 AM(UTC)
klim

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)



wabbit  
#4 Posted : Tuesday, February 12, 2013 4:56:48 AM(UTC)
wabbit

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]
klim  
#5 Posted : Tuesday, February 12, 2013 5:27:06 AM(UTC)
klim

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.
mstt  
#6 Posted : Tuesday, February 12, 2013 1:59:41 PM(UTC)
mstt

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)
Similar Topics
Elimination of Prev Function (Basic Coding Techniques)
by rockerzeus 10/6/2015 6:18:39 PM(UTC)
Need help with PREV function on Highlight (Formula Assistance)
by Leverage 11/4/2013 6:17:00 PM(UTC)
Avoid PREV function (Formula Assistance)
by MetaReader 7/16/2013 8:18:13 AM(UTC)
PREV Function (MetaStock)
by v.trader 11/22/2009 2:10:08 PM(UTC)
PREV function (Formula Assistance)
by dct73 7/29/2009 3:24:29 PM(UTC)
Help for the Code With Non Prev Function (Formula Assistance)
by uasish 10/27/2006 10:19:32 AM(UTC)
Trying to Remove the PREV Function [RESOLVED] (Formula Assistance)
by lcl 1/22/2006 4:06:11 PM(UTC)
Removal of the PREV function [RESOLVED] (Formula Assistance)
by RUAGOODP 7/21/2005 5:00:31 PM(UTC)
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.