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

Notification

Icon
Error

Options
Go to last post Go to first unread
Flexi  
#1 Posted : 15 years ago
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 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?

mstt  
#2 Posted : 15 years ago
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 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 : 15 years ago
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Hi Roy,

The coding gives zero

If(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 zero

flexi
mstt  
#4 Posted : 15 years ago
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 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 : 14 years ago
solero0105

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/9/2010(UTC)
Posts: 1

Why to be so complicated while you can use BarsSince(Data array) for this ???
MS Support  
#6 Posted : 14 years ago
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,973

Thanks: 95 times
Was thanked: 158 time(s) in 153 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
Guest (Hidden)
Similar Topics
Counting bars to locate Fib and Lucas numbers. (Formula Assistance)
by singhvi 13 years ago
Counting bars dilemma [RESOLVED] (Formula Assistance)
by Perigon 19 years ago
Counting bars of previous events without using lastvalue (MetaStock)
by weird 19 years 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.

information You have 1 unread message(s) in your Inbox.