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

Notification

Icon
Error

Options
Go to last post Go to first unread
hk88888  
#1 Posted : Sunday, June 24, 2012 7:27:50 PM(UTC)
hk88888

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2012(UTC)
Posts: 12

I am trying to build a formula that will tell me how many times something has happened since a particular event.

More specifically, How many times has the intraday low fallen below the 20D EMA since the 20D EMA last crossed the 50D EMA.

I can see plenty of other example formulas posted here and in Metastock manuals that show how to count certain events since a number of bars ago... or to count the number of bars since an event happened.... but nothing relating to the number of times something has happened since a particular event.

I think im on the right tracking using something like...Cum(If((L<Mov(C,20,E) AND (BarsSince(Cross(Mov(CLOSE,20,E),Mov(CLOSE,50,E)))> ????..... but that's about as far as I can go....

If anyone can help with this, would greatly appreciate it! Many thanks!





wabbit  
#2 Posted : Sunday, June 24, 2012 8:50:58 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)
Code:

event:={your event};
count:=Cum(event);

reset:={whatever condition resets the counter};

counter:=count-valuewhen(1,reset,counter);

{plot}
counter;



wabbit [:D]

hk88888  
#3 Posted : Sunday, June 24, 2012 9:26:23 PM(UTC)
hk88888

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2012(UTC)
Posts: 12

Hi Wabbit, really appreciate the quick reply.... thank you.... but, I'm still struggling! I input the following formula, but when plotted, it doesn't actually show anything on the chart.... and in an exploration it returns N/A... I think I'm lost with the 'reset' part.....

This formula will actually just be used in an exploration rather than a plot on the chart, if that makes any difference...

event:=L<Mov(C,20,E);
count:=Cum(event);
reset:=(Cross(Mov(C,20,E),Mov(C,50,E)));
counter:=count-ValueWhen(1,reset,counter);
{plot}
counter;
wabbit  
#4 Posted : Sunday, June 24, 2012 10:15:11 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)
my fault...

the counter line contains the error, COUNT not COUNTER

Code:

event:=L<Mov(C,20,E);
count:=Cum(event);
reset:=(Cross(Mov(C,20,E),Mov(C,50,E)));
counter:=count-ValueWhen(1,reset,count);
{plot}
counter;



wabbit [:D]

hk88888  
#5 Posted : Sunday, June 24, 2012 10:33:08 PM(UTC)
hk88888

Rank: Member

Groups: Registered, Registered Users
Joined: 6/25/2012(UTC)
Posts: 12

Ahhh.....Now it works perfect! Cheers and thanks a lot.... Nice to know that there is someone this side of the planet to help out for a change!
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.