Discussions
»
Product and Service Development
»
Formula Assistance
»
Plz Help! Can't figure out how to reference a %age of a MA x number of days ago...
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/21/2005(UTC) Posts: 33
|
I've got the formula primer right in front of me, and I'm trying to reference a percentage of the 50-day moving average, 50 days ago.
for the %age of the 50 day moving average I use
((c-mov(c,50,s)/mov(c,50,s))*100;
then to try and reference that value 50 periods ago I try this
ref(((c-mov(c,50,s)/mov(c,50,s))*100,-50);
and I'm getting some really messed up numbers...
Please Help! I only made it to Calculus 1 in college and I got a C in it!
Thanks
Biff
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Only Wabbit and Jose can do that embedded stuff and survive. Write your code like this and it is a bit easier to read and change. {------------------------} a1:=Mov(C,50,S); {my moving average} a2:=((C-a1)/a1)*100; {my percent} a3:=Ref(a2,-50); {my reference} a3 {my plot} {------------------------} If variable a3 looks strange, you go backwards and plot each variable, a2, a1, etc . to find the error. Hope this helps.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/21/2005(UTC) Posts: 33
|
Thanks for the help my good friend, I'll try that, it looks like it should work.
Merry Christmas, thanks again
Biff
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/21/2005(UTC) Posts: 33
|
Arghhh...for column 2, it says I can't use the column function in that way...argh
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Biff,
Your initial code was so close to being correct - just one ")" in the wrong place which will affect the results of both formulae.
Try these codes and see whether the results are acceptable.
(C-Mov(C,50,S))/Mov(C,50,S)*100;
Ref((C-Mov(C,50,S))/Mov(C,50,S)*100,-50);
Johnl's code is also correct but cannot be used in an exploration unless you delete the last line.
Good back testing!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/21/2005(UTC) Posts: 33
|
that did the trick! thanks for all your help!
Biff
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Plz Help! Can't figure out how to reference a %age of a MA x number of days ago...
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.