Metastock Question - Aussie Stock Forums

1. ## Metastock Question

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...

2. ## Re: Metastock Question

Hi Chorlton,

, to be more specific on the question you asked,

have a look at

llvbars( DATA ARRAY, PERIODS )

3. ## Re: Metastock Question

Hi Weird,

Thanks for the reply... I'll take a closer look at the BarsSince function........

4. ## Re: Metastock Question

Hi.

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

Thanks.

5. ## Re: Metastock Question

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

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.

6. ## Re: Metastock Question

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.

7. ## Re: Metastock Question

Originally Posted by nizar
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

8. ## Re: Metastock Question

Originally Posted by nizar
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

9. ## Re: Metastock Question

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.

10. ## Re: Metastock Question

Originally Posted by buggalug
Not saying that wouldn't work, but you could do:
(C - Ref(C,-26))*100/Ref(C,-26) > 25
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.

11. ## Re: Metastock Question

Originally Posted by nizar
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;

12. ## Re: Metastock Question

Hello Again,

I would really appreciate some further help regarding MS coding

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

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...

13. ## Re: Metastock Question

Chorlton,

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

14. ## Re: Metastock Question

Originally Posted by weird
Chorlton,

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

Hi Weird,

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...

15. ## Re: Metastock Question

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/

16. ## Re: Metastock Question

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.

17. ## Re: Metastock Question

Originally Posted by 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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums