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

Notification

Icon
Error

Options
Go to last post Go to first unread
mbhagra  
#1 Posted : Sunday, May 20, 2007 5:07:56 AM(UTC)
mbhagra

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/6/2006(UTC)
Posts: 5

Hi,
I need a expert and exploration fr the following:
1. Positive reversal: If the scrip crosses the previous day's low and closes above the present day open and the previous day close.
2. Negative Reversal: If the scrip crosses previous days high and closes below previous days close and current open.
3. Key Negative Reversal: Same as negative reversal only thedifference that the scrip closes below the previous days open.

thanks in advance
mbh


[subject edited by wabbit]
wabbit  
#2 Posted : Sunday, May 20, 2007 5:46:52 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)
mbh,

I think you will benefit greatly by reading the MS Users Manual that came with yuor copy of MetaStock. After you have finished reading the Manual, I would strongly recommend that you download the free Equis Formla Primer from the files section and work through all the exercises contained therein.

Armed with this knowledge, yuo will have no problem completing this simple coding project. After doing the required reading and the homework yourself, if you get stuck, please post your best attempt at the code along with a full explanation of what you are trying to achieve to the forum and I am sure one of the good members here will assist you to sort out the bugs.

We aren't here to write your code for you, we are here to help when you get into trouble using MetaStock.



wabbit [:D]

mbhagra  
#3 Posted : Tuesday, May 22, 2007 6:10:50 AM(UTC)
mbhagra

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/6/2006(UTC)
Posts: 5

ok wabbit....hi.. I knew you wont make it easy.So this is what i tried ...fr the first two conditions...not able to get the third one.....also used the same as exploration...plz let me know if i am right? Positive Reversal: L < Ref(L,-1) AND C>Ref(C,-1) AND C < H. Negative Reversal: H > Ref(H,-1) AND C<ref(C,-1) AND C < H. How do i add a volume filter to the above exploration? Thanks and Regards, Mbh
wabbit  
#4 Posted : Tuesday, May 22, 2007 7:01:51 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)
mbh,

If I have understood your requirements properly, or if I haven't, this should help get you started:

mbhagra wrote:
Positive reversal: If the scrip crosses the previous day's low and closes above the present day open and the previous day close.

Code:

CLOSE > Ref(LOW,-1) AND
CLOSE > Ref(CLOSE,-1) AND
CLOSE > OPEN;


mbhagra wrote:
Negative Reversal: If the scrip crosses previous days high and closes below previous days close and current open.

Code:


CLOSE < Ref(HIGH,-1) AND
CLOSE < Ref(CLOSE,-1) AND
CLOSE < OPEN;


mbhagra wrote:
Key Negative Reversal: Same as negative reversal only the difference that the scrip closes below the previous days open.

Code:


CLOSE < Ref(HIGH,-1) AND
CLOSE < Ref(CLOSE,-1) AND
CLOSE < Ref(OPEN,-1) AND
CLOSE < OPEN;


To add a VOLUME filter, just add to the previous conditions:
Code:



AND VOLUME > WhatEverValueOrConditionYouLike;


As I have said before, you will get more out of doing the reading and writing your own codes than having someone else do all the work for you!


wabbit [:D]

amory  
#5 Posted : Tuesday, May 22, 2007 7:16:15 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

Wabbit, where MBH says "crosses previous day's low" doesn't that mean today's movement has to start from below it? such as

and Open<ref(L,-1)

or maybe

and Low<ref(L,-1)

just wondering

wabbit  
#6 Posted : Tuesday, May 22, 2007 8:13:07 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)
dunno???

I had several other idea in my mind when I was writing those snippets...

L<Ref(L,-1) AND H>Ref(L,-1) was another possibility...

Without proper definition, I wouldn't hazard a guess, but I hope mbh has enough to go on with, to write his own codes.


wabbit [:D]

amory  
#7 Posted : Tuesday, May 22, 2007 5:11:44 PM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

Hi Wabbit, MBH!

I've got this :P&V" formula which runs like this:

ROC(close,1,percent)>5 and V>mov(V,50,E)*1.3

where I'm looking for an up-on-good-volume day. I've been adding MBH's positive reversal on as an ALERT with ,5) at the end of it (last 5 days) & got some quite active results, not bad at all. a couple of nice uranium stocks etc.

QUESTION: is it possible to instruct the Explorer that I want the 'alert' (MBH's formula)to apply anywhere within the last 5 days, but NOT ON THE VERY LAST DAY, i.e. today's close?

this problem has come up in the past, hoping there might be an answer to it.

thank you

wabbit  
#8 Posted : Tuesday, May 22, 2007 6:56:00 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)
amory,

The short answer is yes.

The longer answer will have to wait until tonight, unless another member offeres the solution first; I have other obligations today, if they can be fulfilled I will have a coded answr for you either tonight or sometime tomorrow.


wabbit [:D]
amory  
#9 Posted : Tuesday, May 22, 2007 8:28:31 PM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

you are too kind Wabbit! there is not really any urgency. just thought it might be of some general interest, beyond my own "alert"-ness.

many thanks

wabbit  
#10 Posted : Wednesday, May 23, 2007 3:15:28 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)
Amory,

Lets say we have a condition:

Code:

condition:=
CLOSE > Ref(LOW,-1) AND
CLOSE > Ref(CLOSE,-1) AND
CLOSE > OPEN;


We can find if the condition is true on the very last bar (in an exploration, but this can be used in indicator functions too) without using the Alert() function:
Code:


condition:=

CLOSE > Ref(LOW,-1) AND

CLOSE > Ref(CLOSE,-1) AND

CLOSE > OPEN;

{this is the important bit}
condition;



The 'condition' variable returns a boolean or binary value, TRUE or 1 if the criteria are met, or FALSE or 0 if the criteria are not met. The important bit says, "The value of the 'condition' variable must be TRUE or not-zero", so our filter will return all those stocks where the condition is met on the last bar of data. What happens prior to the last bar is not regarded in this filter.

You can extend any condition using the Alert() function.

If we want to find the stocks where the condition is met in the last, say 5 bars, we can use the Alert() function:
Code:


condition:=

CLOSE > Ref(LOW,-1) AND

CLOSE > Ref(CLOSE,-1) AND

CLOSE > OPEN;

{this is the important bit}
Alert(condition,5);



The long way of writing out what the Alert() function is doing in this case is like:
Code:

condition=1 OR
Ref(condition, -1)=1 OR

Ref(condition, -2)=1 OR

Ref(condition, -3)=1 OR

Ref(condition, -4)=1;


Using the Alert() function, we dont care WHEN with the lookback period the event happened, we only care that it happened, so the event must have happened AT LEAST once in the period. (There are other methods that will tell us if the condition EXACTLY x-many times)

To now get to the state when we need to know the condition on the last bar, we can use the Alert() function, but we add the final condition too:
Code:



condition:=


CLOSE > Ref(LOW,-1) AND


CLOSE > Ref(CLOSE,-1) AND


CLOSE > OPEN;



{this is the important bit}
condition=0 AND Alert(condition,5);




We can do this in this case because we want the condition on the last bar to be false.

What would happen if we said the condition had to be true on the last bar? If the condition is true on the last bar, then the Alert() function would also be true! To find for example a system when the condition must have been true on the last bar AND the condition must have been true in the preceeding bars we can use the Alert() function set back using the Ref() function:

Code:




condition:=



CLOSE > Ref(LOW,-1) AND



CLOSE > Ref(CLOSE,-1) AND



CLOSE > OPEN;





{this is the important bit}

condition AND Ref(Alert(condition,4),-1);





Note we changed the lenght of the Alert function to account for the lookback period.

Like with all things computing there is another way to find when a condition has happened in a defined period, or even how many times the event has happened in a deined period, or find out when events in defined periods using the Sum() function as a counter!

Code:




condition:=



CLOSE > Ref(LOW,-1) AND



CLOSE > Ref(CLOSE,-1) AND



CLOSE > OPEN;





{this is the important bit}
Sum(condition,5)>1;





would find those stocks which met the condition EXACTLY once in the last 5 bars

Code:





condition:=




CLOSE > Ref(LOW,-1) AND




CLOSE > Ref(CLOSE,-1) AND




CLOSE > OPEN;







{this is the important bit}

Sum(condition,5)>=1;






would find those stocks which met the condition AT LEAST once in the last 5 bars.

Code:






condition:=





CLOSE > Ref(LOW,-1) AND





CLOSE > Ref(CLOSE,-1) AND





CLOSE > OPEN;









{this is the important bit}
conditon=0 AND Sum(condition,5)>=1;







would find those stocks where the condition was not met on the last bar, but was met at least once in the last 5 bars...

Code:







condition:=






CLOSE > Ref(LOW,-1) AND






CLOSE > Ref(CLOSE,-1) AND






CLOSE > OPEN;











{this is the important bit}

condition=1 AND Ref(Sum(condition,4),-1)=1;







would find those stocks where the condition was true on the last bar and the condition only happened once in the 4 bars previous to thelast bar (ie the last 5 bars)...

etc etc etc


Hope this helps.

wabbit [:D]


amory  
#11 Posted : Wednesday, May 23, 2007 3:48:28 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

Thanks Wabbit, this is really interesting! you are a veritable fountain of knowledge!
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.