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

Notification

Icon
Error

Options
Go to last post Go to first unread
kgmanage  
#1 Posted : Friday, January 20, 2012 9:29:29 AM(UTC)
kgmanage

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 2

Good morning everyone. The code I posted below returns (might return, haven’t tested) a value that I use to measure the volatility of a stock. It chooses the largest 'N' absolute value and that is the volatility for the stock that day. I want to plot this as a 20day moving average (the volatility for that day is the average of the highest N value from the past 20 days). How can I do this? I have come up with a way, but I'll have to produce a ridiculous amount of code. I'm hoping there is a simpler way. N1 := Abs(HIGH-LOW); N2 := Abs(HIGH - Ref(CLOSE,-1)); N3 := Abs(LOW - Ref(CLOSE,-1)); If(N1 > N2 AND N3, N1, If(N2 > N3, N2, N3)) Thanks.
Alan R  
#2 Posted : Friday, January 20, 2012 10:31:22 AM(UTC)
Alan R

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/23/2009(UTC)
Posts: 51

If when you plot your equation If(N1 > N2 AND N3, N1, If(N2 > N3, N2, N3)) on the chart for a given stock and you get the responses you are looking for, then, if I understand what you are wanting to do, all you need to do is average each periods response over the last 20 days. This is simple to do. All you do is:

mov(If(N1 > N2 AND N3, N1, If(N2 > N3, N2, N3)),20,S);

kgmanage  
#3 Posted : Friday, January 20, 2012 11:03:02 AM(UTC)
kgmanage

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 2

Oooo I was not aware that one could nest a statement within that function's argument. I assumed that it had to be a data value!

This makes things a lot easier! [:$] Thank you for your help and a for not telling me to UTFSE.

Alan R  
#4 Posted : Friday, January 20, 2012 11:59:32 AM(UTC)
Alan R

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/23/2009(UTC)
Posts: 51

Your welcome!
wabbit  
#5 Posted : Friday, January 20, 2012 4:39:56 PM(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)
Again, have a search of the forum and look for posts describing the Boolean returns from evaluations; then have a look in the MS Users Manual for orders of precedence, then finally for the ATR() function (or Max() function, if you want to write your own version of ATR()).


wabbit [:D]

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.