Australian (ASX) Stock Market Forum

Metastock Question

Joined
14 April 2007
Posts
317
Reactions
0
Hello All,

Can anyone offer any help on this?

What I want to do is calculate the number of periods between a "specific" bar in the past and the latest period bar.

For example, this "specific" bar could be the lowest Low of say the last 100 periods. Using the LLV function I know how to return the actual value of the specific bar but how can I calculate the number of periods between this period and the latest period bar?

Any help much appreciated...
 
Hi Chorlton,

To answer your question generally, you could use,

barssince( DATA ARRAY )

, to be more specific on the question you asked,

have a look at

llvbars( DATA ARRAY, PERIODS )
 
Hi.

How can you code a rate of change filter of momentum filter in metastock/tradesim?

Thanks.
Wabbit i can see your online. Please~!
 
Nizar....

If we consider that (one of the many definitions) of momentum is:

momentum(data,periods) = 100 * data / Ref(data, -periods)

then we can compute the rate of change (in percentage) as

RateOfChangeofMomentum(periods) = 100 * momentum / Ref(momentum, -periods)

If you want you can scale this value too...


In MSFL:

Code:
prd1:=10;
prd2:=3;
data:=CLOSE;

myMom := data / Ref(data, -prd1);
rocMom := (100 * myMom / Ref(myMom, -prd2)) - 100;

{plot}
rocMom;


We can achieve the same results using the built in functions for momentum and ROC:

Code:
prd1:=10;
prd2:=3;
data:=CLOSE;

rocMom:=ROC(Mo(data, prd1),prd2,%)

{plot}
rocMom;


Hope this helps.

wabbit :D



P.S. All this information is easily discovered by reading your MS Users Manual and completing all of the exercises in the free Equis Formula Primer.
 
Wabbit and others.

Would this be correct for me to put in my entry filter if Im trying to find stocks that have moved more than 25% in the past 26 periods.

The system is weekly so 26 periods = 26 weeks.

roc(C,26,%)>25

Thanks.
 
Wabbit and others.

Would this be correct for me to put in my entry filter if Im trying to find stocks that have moved more than 25% in the past 26 periods.

The system is weekly so 26 periods = 26 weeks.

roc(C,26,%)>25

Thanks.

Not saying that wouldn't work, but you could do:
(C - Ref(C,-26))*100/Ref(C,-26) > 25
 
Wabbit and others.

Would this be correct for me to put in my entry filter if Im trying to find stocks that have moved more than 25% in the past 26 periods.

The system is weekly so 26 periods = 26 weeks.

roc(C,26,%)>25

Thanks.

You have to be very careful how you make your definitions. A computer will do only what you tell it to do; it cannot interpret what you think you mean, so your instructions have to be precise and completely unambiguous.

For a start, be very aware that numbers of weekly bars do not always equate to numbers of weeks. In thinly traded stocks or stocks in prolonged trading halts, the last 26 calendar weeks could be represented by 0 to 26 bars of data; 26 bars could represent a time frame a lot longer than 26 weeks! If you want to conduct calendar based explorations then you are better off using the MS date functions to define the start (and/or end) date for the exploration.

The other factor is; are you looking for stocks that are 25% higher on the last bar than the price 26 weekly bars before the last bar? OR are you looking for stocks that have had a "recovery" from a low price to high price, or drop from a high price to a low price greater than 25% in the last 26 weekly bars? These are all completely different beasts and have to be handled differently.

Again, I point you towards the MS Users Manual and the free Equis Formula Primer to learn about the ROC() function, HHV() and LLV() functions, and the various date functions. HHVBars() and LLVBars() might come in handy, as can ValueWhen() and Cum(1).


Hope this helps.

wabbit :D
 
Wabbit.

Ok my mistake.
I should never have mentioned weeks.

I want to scan for stocks that have increased more than 25% in the last 26 bars.

That means from the low to high price in the last 26 bars, the movement is >25%.

Its an attempt to filter out the "slow" movers.

Buggalug.

Thanks for that. I'll put it in place of my filter, and run some simulations. If I get the same results, it must be the same thing.

If not -- then i'll go with yours.

Thanks.
 
It seems that the above code and my:
roc(C,26,%)>25

Both tell MS to do the same thing?

Results were pretty much identical.

Not sure of your aim, what if it has dipped somewhere in the middle or the 26 bar range? Do you want to capture that?
26BarLowClose := LLV(C,26);
(C - 26BarLowClose)*100/26BarLowClose > 25;
 
Hello Again,

I would really appreciate some further help regarding MS coding :confused:

When comparing the current value of an indicator to its value x periods ago, we can use the Ref(data array, periods) function.

As an example: AD() < Ref(AD(),-1)

However, in my situation the value used for the periods (-1 in the above example) is calculated based on another formula, and therefore the -1 has been replaced with a variable.

As a result, when I try to save the code in MS, I receive the error message "This variable or expression must contain only constant data."

Consequently, is there any way around this as I do not know in advance what the value for the period will be? :(

Any help much appreciated...
 
Chorlton,

look at using the forum dll written by Patrick which allows using variable periods.

You can download it from forum.equis.com
 
Chorlton,

look at using the forum dll written by Patrick which allows using variable periods.

You can download it from forum.equis.com

Hi Weird,

Thanks for the reply.

I tried downloading it from the Equis Forum but as I wasn't a member I couldn't get access to it. I've registered my details on the forum but I'm now waiting for the confirmation email which contains my password..... Its been 24hrs now so not sure if there is some form of problem with the site.... :(

Cheers anyway though...
 
I suggest persisting, I can post another site where you can download the dll only, but you should grab the manual as well which is available on the equis forum site in the download section. The site is worth joining.

You can also grab the dll and manual from the metastock mailing list, which is a yahoo group, in the forum files section, also I recommend joining this.

They are all free, and some of the best resources for sharing and learning metastock,

http://finance.groups.yahoo.com/group/equismetastock/
 
Hi all.

Can anybody help me Im trying to create an ATR trailing exit using MS v9 EOD.

I have downloaded Richard Dale's plugin which was excellent, but that calculates the trailing stop from the HIGH.

Im looking for a trailing stop that is calculated using the CLOSE.

Any ideas?

Nizar.
 
Hi all.

Can anybody help me Im trying to create an ATR trailing exit using MS v9 EOD.

I have downloaded Richard Dale's plugin which was excellent, but that calculates the trailing stop from the HIGH.

Im looking for a trailing stop that is calculated using the CLOSE.

Any ideas?

Nizar.

All good now guys.
Problem solved.
 
Top