MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Periods Loaded and First Loaded Closing Price
Custom Indicators for Periods Loaded and First Loaded Closing Price

To: metastock-list@xxxxxxxxxxxxx
Subject: Custom Indicators for Periods Loaded and First Loaded Closing Price
From: Charles Kalb <chaskalb@xxxxxxxxxxxxxxxx>
Date: Tue, 06 Jan 1998 16:24:31 -0600
Resent-Date: Tue, 6 Jan 1998 15:45:57 -0700
Resent-From: metastock-list@xxxxxxxxxxxxx
Resent-Message-ID: <"D8s4l1.0.pw7.aGhiq"@mail.equis.com>
Resent-Sender: metastock-list-request@xxxxxxxxxxxxx


Hello All,

I have been using MetaStock v6.5 for about four months and this is my first post to the list. I'd like to offer a little something which might be of use to someone and hopefully get a question answered. I have developed the following custom indicator for the number of periods loaded in a displayed chart:

NumPeriods:= Sum(1, LastValue(Cum(1)));
NumPeriods {Returns a single point at the right-hand edge of chart with the number of periods loaded in the chart.}

It is interesting that I had to use three MetaStock language functions to arrive at a constant which must be embedded somewhere within MetaStock when a chart is loaded. It would be nice if Equis had provided a function which would give the number of loaded periods directly.

But I digress, my objective is to develop a custom indicator which gives the "Buy and Hold" performance of a security, something which is useful to compare with the results from System testing. Such an indicator requires the first loaded value of the closing price. I attempted, unsuccessfully, to use the above number of periods loaded in the chart to come up with an expression for the first loaded CLOSE:

NumPeriods:= Sum(1,LastValue(Cum(1)));
1stCLOSE:= REF(CLOSE, - (NumPeriods - 1));
1stCLOSE {Returns a single point with the value of the CLOSE for the first period loaded in the chart.}

This custom indicator for the first loaded CLOSE did not work because the MetaStock language will not accept a nonconstant value for the periods portion of the REF function. By manually inserting the number of loaded periods I verified that the above relation is correct but I want an indicator which automatically inserts the correct periods loaded. Once the first loaded CLOSE is available it is a trivial extention to define the "Buy and Hold" performance in an indicator.

Does anyone know how to reference the first loaded value of anything in MetaStock?


Charles Kalb
chaskalb@xxxxxxx

RE: Custom Indicators for Periods Loaded and First Loaded Closing Price

To: metastock-list@xxxxxxxxxxxxx
Subject: RE: Custom Indicators for Periods Loaded and First Loaded Closing Price
From: Charles Kalb <chaskalb@xxxxxxxxxxxxxxxx>
Date: Thu, 08 Jan 1998 23:47:58 -0600
CC: aflood@xxxxxxxx, amcnichol@xxxxxxxxx
Resent-Date: Thu, 8 Jan 1998 23:01:41 -0700
Resent-From: metastock-list@xxxxxxxxxxxxx
Resent-Message-ID: <"XeifK1.0.o-4.3rRjq"@mail.equis.com>
Resent-Sender: metastock-list-request@xxxxxxxxxxxxx


Thanks to Allen at Equis and Aongas for responding to my question directed at formulation of a "Buy and Hold" custom indicator. Just after my post I came across a way to create this indicator using the predefined Performance indicator, but their comments were instructive and useful nonetheless. Thought I'd share the final indicator with the list. To compare the "Buy and Hold" performance with the results from a System test drop the following custom indicator into the same Equity Curve inner window that the System test produces. Change the default initial equity to whatever you normally use in System tests.


Periods Loaded and First Loaded Closing Price I

InitialEquity:= Input("Enter the initial equity",100,10000,3000);
Equity:= InitialEquity*( 1 + Per()/100);
Equity

 

Note: Another way to arrive at the identical results is:

 


Periods Loaded and First Loaded Closing Price II

InitialEquity:= Input("Enter the initial equity",100,10000,3000);
1stClose:= ValueWhen(1, Cum(1) = 1, CLOSE);
Equity:= InitialEquity*CLOSE / 1stClose;
Equity

 

Indebted to Allen for suggesting the ValueWhen function to find the first loaded CLOSE.

Aongas suggested:

> To solve the "buy and hold" question, why not just create a System that
> enters a long position:
> c > 0;
> Don't put anything in for the exit condition and the system will then
> calculate the total return and percentage gain for the available data.

This also works but requires a separate System test; I found the custom indicator approach more useful for my purposes. Thanks again.

Charles

[4191]

Source / From: TOP
http://purebytes.com/archives/metastock/

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!