Error

 Previous Topic Next Topic
 Flexi #1 Posted : Monday, September 27, 2010 10:34:55 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 5/27/2006(UTC)Posts: 135 Have an indicator A that plot 0 or 1 and indicator B that plot +1 or -1 ONLY if indicator A reset to zero. Wanted to count the no of bar while indicator A is at +1 and indicator B is +1 and count the no of bar while indicator A is at +1 and indicator B is -1 Using And does not seems to have statisfying coding. How to do this?
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 mstt #2 Posted : Tuesday, September 28, 2010 12:33:42 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 7/25/2005(UTC)Posts: 1,042Was thanked: 57 time(s) in 54 post(s) Hi Flexi Use the Cum() funtion with the logical condition you want placed inside the function. Cum( Fml("Indicator A") {=1} AND Fml("Indicator B") =1 ); Indicator A can only return values of 1 or 0 (TRUE or FALSE) so you don't need to qualify the expression with "=1". Indicator B, on the other hand, returns either +1 or -1, and as both of these values will be regarded by MetaStock as TRUE you must qualify the expression with "=1". The only MetaStock tool that regards negative numbers as FALSE is the Enhanced System Tester. Hope this helps. Roy
 Flexi #3 Posted : Tuesday, September 28, 2010 2:12:01 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 5/27/2006(UTC)Posts: 135 Hi Roy,The coding gives zeroIf(indicator A =1,Cum(1),0)Tried the above but the coding gives a cum value rather than the differences value Wanted the value to gives just the number of bars if indicator A is at +1 and reset to zero if indicator A is at zeroflexi
 mstt #4 Posted : Tuesday, September 28, 2010 12:48:32 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 7/25/2005(UTC)Posts: 1,042Was thanked: 57 time(s) in 54 post(s) Hi Flexi Sorry, I misunderstood your request. I'll take another look at it if no-one else comes up with a solution. Roy
 solero0105 #5 Posted : Tuesday, November 23, 2010 3:12:38 AM(UTC) Rank: NewbieGroups: Registered, Registered UsersJoined: 11/9/2010(UTC)Posts: 1 Why to be so complicated while you can use BarsSince(Data array) for this ???
 MS Support #6 Posted : Monday, November 29, 2010 1:42:12 PM(UTC) Rank: Advanced MemberGroups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)Posts: 1,866Thanks: 79 timesWas thanked: 149 time(s) in 145 post(s) barssince should work. Use barssince to look back to the last time the condition you are counting was NOT true. nest that inside an IF that report 0 if the condition is not try and barssince if it is.
 Users browsing this topic
 Similar Topics Counting bars to locate Fib and Lucas numbers. (Formula Assistance) by singhvi 7/1/2012 3:19:58 AM(UTC) Counting bars dilemma [RESOLVED] (Formula Assistance) by Perigon 6/5/2006 8:34:52 AM(UTC) Counting bars of previous events without using lastvalue (MetaStock) by weird 2/4/2006 9:17:15 AM(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.