Discussions
»
Product and Service Development
»
Formula Assistance
»
Need help with 'number of occurrences since an event' formula
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!
|
|
|
|
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]
|
|
|
|
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;
|
|
|
|
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]
|
|
|
|
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)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Need help with 'number of occurrences since an event' formula
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.