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

Notification

Icon
Error

Options
Go to last post Go to first unread
Perigon  
#1 Posted : Monday, June 5, 2006 8:34:52 AM(UTC)
Perigon

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/24/2005(UTC)
Posts: 7

Hey gys! Im trying to make a formula that's counting the days my condition have been true. The problem here, is that metatocks built-in function for counting bars only calculates the number of bars with criteria true WITHIN a fixed number of reference bars ie. it return 13 true bars of a period of 50 bars, without any relations to WHEN the criteria was true. What I want to do, is that I want to measure how many days IN A ROW that my criteria has been true. Ie. If yesterday was true, then it checks the day before yesterday and so on.. but if yesterday wasn't true, it only return a zero... you get my point? I think the only way to solve this is with a loop, but I don't know how to state the criteria in the loop.. anyone that can help me / give me some tips? Thanks in advance! /Perigon
wabbit  
#2 Posted : Monday, June 5, 2006 9:12:36 AM(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)
Have you tried using Roy Larsens's free signal counter? --8<------------------------------ {Signal Counter} {© 2003 Roy Larsen} {rlarsen@man.quik.co.nz} a:=C<Ref(C,-4); {signal to count} b:=C>=Ref(C,-4); {signal to reset} i:=Cum(a+b>-1)=1; f:=BarsSince(i OR a)<BarsSince(i OR b); g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); If(f,g+1,g); --8<------------------------------ Hope this helps. wabbit :D
mstt  
#3 Posted : Monday, June 5, 2006 9:13:34 AM(UTC)
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)
Perigon There are several ways to do this. Here's one you can try first. BarsSince("my condition"=FALSE); Roy MetaStock Tips & Tools
Perigon  
#4 Posted : Monday, June 5, 2006 9:16:33 AM(UTC)
Perigon

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/24/2005(UTC)
Posts: 7

I've tried them both, and they do work :-) Tough the last one is a little bit easier :-) Thanks mates! Good trading..
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.