Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
Hi Gang,
I was wondered how I would write an explorer to look for say a crossing of the 50 dma over the 200 dma "within the last x days".
I've got the cross part Cross(Mov(C,50,E), Mov(C,200,E)), I just don't know how to say "within the last x days".
Thanks in advance for your help!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Try this:
[code:1:9e17e2d4e4]event:=Cross(Mov(C,50,E),Mov(C,200,E));
alertPds:=21;
Alert(event,alertPds)
[/code:1:9e17e2d4e4]
jose '-)
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
Jose,
That worked, thank you very much!
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
Actually, I may have spoken too soon.
I set the alertPds: =5 thinking it would find me stocks where the 50 dma crossed over the 200 dma in the LAST 5 bars. When I visually inspected the charts this was not the case. The 50 dma had crossed the 200 dma, but in the distant past, certainly not in the last 5 bars.
What am I doing wrong?
Thanks again.
|
|
|
|
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)
|
CK
You're probably running the exploaration set to "Load Minimum Records". For a 200 day EMA you need to set that to between 500 and 1000 records to get an accurate 200 day EMA. Longer is better. As a rule of thumb you should force an exploration with an EMA to load about 5 times as much data as the longest ema periods value in your explorations formula. The same rule of thumb applies to explorations using any function with Wilders() or an EMA internally. This includes RSI(), ADX(), etc. etc. etc..
Also, the Alert function doen't extend an alert with the Explorer when it's set to minimum records. Technically it would work with 221 bars set, as per Jose's Alert() example, but the 200 day EMA would probably be so away from the chart value of the same EMA for the alert to be totally useless anyway.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
Roy,
I have it set to load 2000 periods. After looking into it further it seems the formula is in fact working properly. What isn't working properly, it seems, is the drawing of the MA's. I have compared the 50 and 200 MA's I am getting with MetaStock with other charting software online and I see that the MetaStock MA's are way different than the ones I am referencing. I have the time periods set to 200 and 50 respectively and I have it set on exponential and price field, close. The other software I am looking at also is using exponential so they should be the same, but the MetaStock ones are wayyyyy off.
Probably something simple I am missing. Any ideas?
Thanks.
|
|
|
|
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)
|
CK
The MetaStock method of calculating an EMA may well be different from other charting packages - I simply don't know. The MS method retains a fragment of ALL past historical data, not just data within the "periods" parameter.
For example, a 7 period EMA adds 25% of new data (current bars close?) on each bar, and retains 75% of old data. The proportion of existing data retained or preplaced is determined by the ratio of 2/(n+1), where "n" is the periods parameter. The ratio for Wilders Smoothing is 1/n.
{7 Period Exponential Moving Average}
R:=2/(7+1);
If(Cum(1)=1,C,PREV*(1-R)+C*R);
Without knowing how other packages calulate an EMA it's difficult to assign "right" and "wrong". I'm sticking with "different". The MetaStock user manual spells out how its EMA is constructed. You'd have to check whether the other packages have the same information. That might at least explain the difference, and a remedy might follow on from there.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
That could explain a little difference but the difference I am seeing is fundamentally huge compared to 3 or 4 other charts I've look at, all them are very very similar.
I don't know, I guess I will have to do some digging.
Thnx
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 8/14/2005(UTC) Posts: 3
|
I am curious about a slight change to the condition mentioned about representing a single cross. How could it be written if one wanted to see the cross of the 9 of the 21, then the 21 of the 50 day moving average all within a 10 bar period of time?
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/12/2005(UTC) Posts: 141 Location: Brooklyn,NY
|
ckstarrrr,
If the difference is visual check how or where your plotting your scale for the moving averages.When you plot your 200 ma it should ask you about the scale:"merge left"," merge right", etc.Hope it helps.
|
|
|
|
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)
|
Rhone
Try this
BarsSince(Cross(Mov(C,9,E),Mov(C,21,E)))<11 AND Cross(Mov(C,21,E),Mov(C,50,E));
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/7/2005(UTC) Posts: 1,346
|
hey ckstarrrr..... many sites will have differing ma values but was wondering which sites/software were you comparing meta to..... that would give us a reference....h
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
I use bigcharts.com, yahoo.com and stockcharts.com
The problem I am having is with the display of the MA's because the exploration works, ie: it shows me stocks where the 50dma has crossed the 200dma. However on visual inspection the 2 MA's are miles apart on MetaStock.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Well try this, once your chart is open, right click on the first ma and select scaling, select "Merge with scale on right"
Do the same with the second MA .... Do they cross now?
Patrick :mrgreen:
|
|
|
|
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)
|
CK
I wonder if the reason the two MAs are "miles apart" is because one or both of them are unscaled instead of being locked to the same scale as the price chart. Right click on each MA in turn and select the appropriate scale (Left or Right).
Another way to check the relative values of price and MAs is to open the data window (crosshairs on taskbar) and read off the values while moving the cursor over the relevant bars.
Exploration columns are simply indicators without a visual output (last value report only), so there's no valid reason why a chart and exploration would tell you different things except for when the amount of data loaded is different from one to the other. Whether you know it or not everything is under your control. When something doesn't look right on a chart there's always a good reason, never a problem with MetaStock in my experience.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 9/27/2005(UTC) Posts: 29
|
Thanks everybody for your help, the scaling was the issue, all fixed now!! Thank you thank you!
|
|
|
|
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.