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

Notification

Icon
Error

Options
Go to last post Go to first unread
dexter  
#1 Posted : Wednesday, December 1, 2010 6:20:50 AM(UTC)
dexter

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/28/2010(UTC)
Posts: 2

Hi, I'm trying to build an expression were I check for a closing above a moving average, and to see how long that condition has been true, ie how many days the stock has been above the moving average. I want to use it in an explorer where I search for stocks that's currently trading above its MA and be able to sort them or filter by how many days that's been true. Is this possible in MS?
wabbit  
#2 Posted : Wednesday, December 1, 2010 6:30:13 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)
Without getting into philosophical arguments: the count of the number of bars above the MA is the BarsSince() the price was below the MA.



wabbit [:D]

dexter  
#3 Posted : Wednesday, December 1, 2010 12:46:41 PM(UTC)
dexter

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/28/2010(UTC)
Posts: 2

Well, I guess I'm not a programmer.... I've tried the formula If(C>Mov(C,100,E),BarsSince(Cross(C,Mov(C,100,E))),0) The thing that puzzles me is that when I apply the indicator Moving Average with Exponential 100 there are lots of charts with prices closing below the EMA at the end of the chart... Other MA's like the MS11 - adaptive Moving Average, produces a line where prices close above. So, why do they differ?
henry1224  
#4 Posted : Thursday, December 2, 2010 6:38:25 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Dexter,

In your statement

If(C>Mov(C,100,E),BarsSince(Cross(C,Mov(C,100,E))),0)

it will count the number of bars since the cross of c and the MA as long as the close is greater than the MA and it will stop and plot a 0 if the close is equal or less than the MA

BarsSince(Cross(C,Mov(C,100,E)))

will continue to count the number of bars since the cross of C and the ma until the next crossing


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.