What is CLOSE at First Bar and Last Bar

Mike T

Newbie
Messages
3
Likes
0
Using the Metastock language,I'd like to find the difference between the CLOSE value of the last bar loaded and the CLOSE value of the first bar loaded,so:

CLOSE at last bar - CLOSE at first bar

FWIW, the no of bars loaded is given by cum(1)

Can you refer to specific bars? The Ref() function doesn't seem to help here as far as I can see.

Any help appreciated

Thanks

Mike
 
You can only use a constant for the number of periods in the Ref function as far as I know.
This should work but since I don't have metastock its only an educated guess.

Code:
firstClose:=ValueWhen(1, Cum(1) = 1, CLOSE);
lastClose:=CLOSE;
result:=lastClose-firstClose;
result;
 
Thanks

Sven,

Yes,it works.I've just used it in Explorer.

Thanks.Much appreciated.

Mike
 
Top