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?
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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 ???
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,957
Thanks: 91 times Was thanked: 155 time(s) in 150 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 |
|
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.