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

Notification

Icon
Error

Options
Go to last post Go to first unread
mydancher2  
#1 Posted : Thursday, September 20, 2007 9:41:19 PM(UTC)
mydancher2

Rank:: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/14/2007(UTC)
Posts: 7

Hi

I trying to find stocks crossing a MA 0-1 occurrence for the past x periods.

Is this correct? And can it be improved? Many thanks.

x:=200

ma:=mov(c,200,e)

If(Sum(Cross(C,ma),x) <=1,1,0)

wabbit  
#2 Posted : Thursday, September 20, 2007 10:11:47 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)
Hi mydancher2,

Your code is correct as far as it produces a result, but only you can know if the results are what you are looking for!

When you make a comparison, =, <>, >=, <= etc, the result is a boolean TRUE or FALSE, either the expression was true or it wasn't. MS synthesises the result as 1 for TRUE or 0 for FALSE, so you don't have to use the If() function to return 1 or 0 as MS is already doing this for you.

Code:
x:=200;
event:=Cross(C,mov(c,200,e));
Sum(event,x)<=1



Hope this helps.

wabbit [:D]

mydancher2  
#3 Posted : Thursday, September 20, 2007 10:32:27 PM(UTC)
mydancher2

Rank:: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/14/2007(UTC)
Posts: 7

thanks, wabbit.

I expect the results to show stocks with 0 or 1 bar crossing but I see some stocks with 4-5 bars cutting across the specified 200 ma?

wabbit  
#4 Posted : Thursday, September 20, 2007 11:02:23 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)
... is this the result of an exploration, then comparing the exploration with the chart?

Have you loaded enough data into the exploration to allow the accurate computation of the 200 bar EMA? You need to load AT LEAST 1000 bars to compute the ema...


wabbit [:D]


mydancher2  
#5 Posted : Friday, September 21, 2007 2:37:06 AM(UTC)
mydancher2

Rank:: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/14/2007(UTC)
Posts: 7

Hi Wabbit, yes the results came from the exploration as shown below:

=============================

x:=200;
event:=Cross(C,Mov(C,200,E)); { is the event is true only when price closed below ema200 or so long the high and low crosses?}

(colA < colB AND colB < colC) AND (Sum(event,x)<=1 )

=======================================

where colA, colB, colC is ema200, ema100 and ema50 respectively.

how can i post a snapshot of the chart with bars > 1 crossing the moving avg?

and yes, the explorer loaded 2000

wabbit  
#6 Posted : Friday, September 21, 2007 8:04:35 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)
The code Cross(C, Mov(C,200,E)) will return TRUE when the CLOSE crosses up through the MA, only the CLOSE price is concerned here as there is no reference to HIGH and LOW.

If you are looking for the scenario where the HIGH was previously below the MA and on the next bar the LOW is above the MA, then you need to code this 'event' seperately.

Something like this might help:
Code:
x:=200;
ema:=mov(C,200,e);
event:= L>ema AND Ref(H<ema,-1);
sum(event,x)<=1;


Hope this helps.

wabbit [:D]



mydancher2  
#7 Posted : Sunday, September 23, 2007 8:05:11 PM(UTC)
mydancher2

Rank:: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/14/2007(UTC)
Posts: 7

thanks wabbit! will try it out this evening.

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.