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)
|
|
|
|
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]
|
|
|
|
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?
|
|
|
|
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]
|
|
|
|
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
|
|
|
|
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]
|
|
|
|
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.