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

Notification

Icon
Error

Options
Go to last post Go to first unread
stinkray  
#1 Posted : Thursday, August 4, 2016 6:53:24 AM(UTC)
stinkray

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/4/2012(UTC)
Posts: 12

Thanks: 4 times

If(C>Mov(C,200,S),BarsSince(Cross(C,Mov(C,200,S))),0)

The above formula counts the number of  periods  since closing price crosses above 200 SMA.

How should I change the formula to show the number of periods since closing price crosses below 200 SMA.

 

Appreciate help. Thanks

mstt  
#2 Posted : Thursday, August 4, 2016 9:00:04 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)
Hi stinkray The changes you need are quite simple - change the "Greater Than" symbol, >, to a "Less Than" symbol, <, and then reverse the two parameters inside the Cross() function. Here's the formula. If(C<Mov(C,200,S),BarsSince(Cross(Mov(C,200,S),C)),0); Roy
thanks 1 user thanked mstt for this useful post.
stinkray on 8/25/2016(UTC)
stinkray  
#3 Posted : Thursday, August 4, 2016 5:08:31 PM(UTC)
stinkray

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/4/2012(UTC)
Posts: 12

Thanks: 4 times
Hi Roy Thank you very much for your help. Stinkray
stinkray  
#4 Posted : Friday, August 5, 2016 2:47:53 PM(UTC)
stinkray

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/4/2012(UTC)
Posts: 12

Thanks: 4 times
Hi Roy If(C<Mov(C,200,S),BarsSince(Cross(Mov(C,200,S),C)),0); If I want to include the current period into the counting of bars since cross below 200 SMA, how do I code it? Regards Stinkray
mstt  
#5 Posted : Friday, August 5, 2016 9:34:07 PM(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)
Hi stinkray I don't see what the problem is. Can you shed a little more light on the situation? Roy
stinkray  
#6 Posted : Saturday, August 6, 2016 5:13:48 PM(UTC)
stinkray

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/4/2012(UTC)
Posts: 12

Thanks: 4 times
Hi Roy No problem to If(C<Mov(C,200,S),BarsSince(Cross(Mov(C,200,S),C)),0); The above formula counts the number of periods (days) where the stock crosses below 200 SMA prior to the current period (day). This countback does not include the current period (day) which is also below 200 SMA How do I tweak the formula to include the current period (day) into the countback? Thanks Stinkray
mstt  
#7 Posted : Sunday, August 7, 2016 12:20:24 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)
Hi Stinkray Adding 1 at either end of the BarsSince() function works for all except the first Cross() event and the first valid bar. Hope this helps. This not perfect but check it out. If(C>Mov(C,200,S),1+BarsSince(Cross(C,Mov(C,200,S))),0); If(C<Mov(C,200,S),1+BarsSince(Cross(Mov(C,200,S),C)),0); Roy
thanks 1 user thanked mstt for this useful post.
stinkray on 8/25/2016(UTC)
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.