Rank: Member
Groups: Registered, Registered Users Joined: 6/25/2012(UTC) Posts: 12
|
Im not much of a wizard when it comes to writing Metastock formulas, so hope someone can help me overcome my struggle with this..
I just want to highlight (using expert advisor) all the bars FROM when the 20 EMA crosses the 50 EMA UNTIL the 100 day stochastic closes below 25 (but thereafter it shouldnt highlight any bars until the next time the 20 EMA crosses down through 50 EMA) .
I was trying to play around with the 'latch' formulas elsewhere on the forum because it was the nearest thing I could find that would vaguely do the job (but it doesnt!), so I'm hoping someone with better expertise could show me 'the proper' way to do it.
The Fmls Im using are: Stoch(100,3) and Cross(Mov(C,50,E),Mov(C,20,E))
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)
|
Use a count-and-reset formula to make this happen; use this as a template: Code:
count:={the thing you want to count};
reset:={what conditions resets the counter};
count:=cum(count);
counter:=count - ValueWhen(1,reset,count);
{return}
counter=1;
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 6/25/2012(UTC) Posts: 12
|
Thanks Wabbit... appreciate the quick reply..however, that gives me pretty much the same result as what I had tried with the 'latch' formulas... It just shows me the FIRST time that the 200 Stoch falls below 25 after the 50/20 crossover.
Whereas, what Im really looking for is to highlight ALL the bars from the moment the 50 crosses the 20 until the 20 Stoch reaches the 25 level.... is that possible?
count:=Stoch(100,3)<25; reset:=Cross(Mov(C,50,E),Mov(C,20,E));
count:=Cum(count); counter:=count - ValueWhen(1,reset,count);
{return} counter=1;
|
|
|
|
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)
|
OK... I think I have a better idea of your issue: you don't need a counter as you just need BarsSince() Code:
set:=Cross(Mov(C,50,E),Mov(C,20,E));
reset:=Stoch(100,3)<25;
{return}
BarsSince(set)<BarsSince(reset);
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 6/25/2012(UTC) Posts: 12
|
Thanks again Wabbit.. that's exactly what I was after, as strange a formula as it might seem! Have been playing around with this formula for 2 days now... so Im very thankful,believe me! Cheers.
|
|
|
|
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.