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

Notification

Icon
Error

Options
Go to last post Go to first unread
underground  
#1 Posted : Wednesday, June 29, 2005 5:29:12 PM(UTC)
underground

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2005(UTC)
Posts: 37

Ok I'm trying to write a really simple formula and for some reason it just plot's a +1 value???? I want to create an indicator to do this, If increasing plot +1 and if decreasing plot -1. But for some reason it does not plot right. I can create two seperate indicators to do what I want but I would like to combine them. Seperate Indicators: If formula X is increasing plot +1, so it would look like this If(Fml("Name")>Ref(Fml("Name"),-1),1,0) If formula X is decreasing plot -1, so it would look like this If(Fml("Name")<Ref(Fml("Name"),-1),-1,0) My attempt to combine them: If(Fml("Name")>Ref(Fml("Name"),-1),1,0) OR If(Fml("Name")<Ref(Fml("Name"),-1),-1,0) But when I do that it does not plot right? Can any one help me out?
Patrick  
#2 Posted : Wednesday, June 29, 2005 5:31:32 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
You need to nest your if statements like so : If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1, 0)) The rate of change is just to look prettier ... Patrick :mrgreen:
Patrick  
#3 Posted : Wednesday, June 29, 2005 5:32:57 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Though if the formula is the same why not just If(Roc(FML('Name"),1,$)>0,1,-1) Patrick :mrgreen:
underground  
#4 Posted : Wednesday, June 29, 2005 5:43:33 PM(UTC)
underground

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2005(UTC)
Posts: 37

Thanks that worked:) If I wanted to add to it so that I had another two formulas like that would I just and this: If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1,0)) AND If(Roc(FML('Name2"),1,$)>0,1, If(Roc(FML('Name2"),1,$)<0,-1,0)) ??????
Patrick  
#5 Posted : Wednesday, June 29, 2005 5:48:17 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
:-k ... Not really ... Version 1 If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1,0)) + If(Roc(FML('Name2"),1,$)>0,1, If(Roc(FML('Name2"),1,$)<0,-1,0)) It would then plot from -2 to 2 Version 2 If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1,0)) ; If(Roc(FML('Name2"),1,$)>0,1, If(Roc(FML('Name2"),1,$)<0,-1,0)) It would then plot 2 lines going from -1 to 1, you could change the color of each line ... Patrick :mrgreen:
underground  
#6 Posted : Wednesday, June 29, 2005 6:44:25 PM(UTC)
underground

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2005(UTC)
Posts: 37

Thanks for the help I think I have it :D
wabbit  
#7 Posted : Wednesday, June 29, 2005 11:08:38 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)
underground, Patrick and all, Programming in MS can be made a little easier if we remember a little 'trick'. In the code: If(Roc(FML('Name"),1,$)>0,1,0) we ask MS to return a figure of 1 if the statement is true and 0 if it is false. The VERY SAME can be achieved with the simpler, shorter code: Roc(FML('Name"),1,$)>0 If the statement above is true then a figure of 1 is returned, 0 otherwise. This means that we can create 'binary' waves and the like without using any If() statements: If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1,0)) AND If(Roc(FML('Name2"),1,$)>0,1, If(Roc(FML('Name2"),1,$)<0,-1,0)) returns values of 1 iff (if and only if) BOTH conditions Roc(FML('Name"),1,$)>0 and Roc(FML('Name2"),1,$)>0 are true, 0 otherwise, can be written to return the same: Roc(FML('Name"),1,$)>0 AND Roc(FML('Name2"),1,$)>0 Code extensions Lets take this a little further.... To see when one condition or both conditions are true try adding them: Roc(FML('Name"),1,$)>0 + Roc(FML('Name2"),1,$)>0 wil return 2 when both conditions are true, 1 when either condition is true and 0 when neither condition is true. You could also tell which is condition is true by taking the difference (this is exceptionally powerful when the conditions need to be defined as mutually exclusive): Roc(FML('Name"),1,$)>0 - Roc(FML('Name2"),1,$)>0 will return 1 when only the first condition is true, -1 when only the second condition is true, 0 when neither condition is true, (and here's the powerful part) 0 when BOTH conditions are true! Hope this helps wabbit :D
Patrick  
#8 Posted : Thursday, June 30, 2005 12:13:28 AM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: ),1,$)> Go to Quoted Post
I know but he wanted -1 as the opposite result .... Patrick :mrgreen
henry1224  
#9 Posted : Thursday, June 30, 2005 12:27:56 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
If(Roc(FML('Name"),1,$)>0,1, If(Roc(FML('Name"),1,$)<0,-1,0)); If(Roc(FML('Name2"),1,$)>0,2, If(Roc(FML('Name2"),1,$)<0,-2,0)); This will plot 2 lines Fml name 1 will plot 1 or -1 or 0 Fml name 2 will plot 2 or -2 or 0
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.