Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
For experts only,
Hi there,
How to make MetaStock draw an horizontal line at the Close of the day when a 21-day EMA crossed above the price and stay flat until the 21-day EMA crossed below the price when again, it will stay flat until it crosses above the price?
All I know is
If(cross(Mov(c,21,E),c),c,if(cross(c,Mov(c,21,E),c, ???))
With this simple formula I get a line that follows the prices but does not stay flat until the opposite condition is met.
HELP ….
|
|
|
|
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)
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Hi Wabbit,
Thanks for replying.
I know most of Metastock functions including ValueWhen, but I can't make it work.
If(Cross(Mov(C,21,E),C),C,If(Cross(C,Mov(C,21,E)),C, ValueWhen(1,Cross(Mov(C,21,E),C),21)))
This formula plots an indicator, but not a horizontal line on the chart itself, line that should change when the opposite incident occurs.
I know it’s more than the simple formula above I was able to come up with.
This is why I ask the help of experts …
|
|
|
|
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)
|
Break the code up into parts, using variables: Code:
data:=CLOSE;
MA:=mov(data,21,e);
CrossUp:=Cross(data,MA);
CrossDn:=Cross(MA,data);
{plot}
if(barssince(CrossUp)<barssince(CrossDn), valuewhen(1,CrossUp,data),valuewhen(1,CrossDn,data));
You can neaten this up with initialisation functions, but see how you go with this first. wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Well, well, well, Wab, this is big science for me, but now, because of you, I know more than yesterday.
Thanks.
|
|
|
|
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)
|
There is no information in my post that cannot be found in the MS User Manual and the free Equis Formula Primer.
wabbit [:D]
|
|
|
|
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.