[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Testing



PureBytes Links

Trading Reference Links

Tim/

This type of question comes up from time to time and the usual answer
from both the List and from Equis Support is that it can't be done.  My
own query some time ago met the same fate.  The problem is that even
though the System Tester creates a file with the entry data, you cannot
refer to it.

There is a way though.  The trick is to create a binary indicator which
duplicates your entry and exit rules in the regular MetaStock program,
not in the System Tester.  Call it something like "TradeStatus", and in
skeletal form it would go something like this.  (Assuming your entry
rule is a new high breakout).

GoLong:= High > Ref(HHV(High, 20),-1) AND Ref(TradeStatus,-1)<>1;
ExitLong:= High > ValueWhen(1, GoLong=1 {True}, C) + 0.5 AND
Ref(TradeStatus,-1)=1;
TradeStatus:=If(Prev<>1 AND GoLong=1 {True},1,
{Else}If(Prev=1 AND ExitLong=1 {True},0,
{Else}Prev));
TradeStatus

(I haven't actually programmed the above, so nothing is guaranteed).

You can add in short side trades so that TradeStatus reads 1 for long,
-1 for short and 0 for flat.  Be warned though that the use of the Prev
function makes everything glacially slow.

Once the binary indicator is operational it is easy to program the
System Tester.  You can use the value of TradeStatus and whether GoLong
and ExitLong are true.  If everything works out correctly the System
Tester Buy and Sell indicators will coincide with changes in the value
of the binary indicator.  (As an option, instead of plotting the binary
indicator you could create an Expert ribbon to show in colour whether
you are long, short or flat).

Your post sounds as if you have a good handle on coding logic, so I'll
leave you the fun of tweaking the details.  If you (or anyone) see ways
to improve this technique, and in particular to avoid the use of the
Prev function, please pass the information along.

Harvey Pearce, Victoria, B.C., Canada
=====================================



TKruzel wrote:
> 
> MetaStocker's,
> 
> There is a type of trading scenario that I would like to test for
> in MetaStock. So far I have been unsuccessful in trying to do it.
> If any of you out there have succeeded testing the following
> scenario (with MetaStock or any other product) I would appreciate
> hearing from you.
> 
> Imagine the following trade. At some price bar, a buy signal is
> triggered and I enter the trade. The entry price is the CLOSE of that
> bar. Now, I wish to exit the trade at the first instance that the stock
> trades at CLOSE+1/2 (a half point of profit). To do this I must check
> the HIGH of each subsequent bar. The CLOSING prices of the subsequent
> bars may never achieve a value of CLOSE+1/2, but the HIGH of the very
> next bar might very well achieve a value of CLOSE+1/2. As soon as the
> HIGH exceeds CLOSE+1/2 I would exit the trade with 1/2 point profit.
> 
> The System Tester bundled with MetaStock does not allow for the above
> type of scenario. The System Tester requires using the same price on
> each bar for both entries and exits (i.e. CLOSE/CLOSE, OPEN/OPEN, etc.).
> So, if the FUTURE CLOSES never get above the value of ENTRY CLOSE+1/2
> then MetaStock would end up counting the trade as a looser (assuming
> that some STOP would take you out). However, the trade may have
> actually been a winner because some future HIGH did exceed the value
> of CLOSE+1/2.
> 
> Because of this limitation in the MetaStock System Tester I have been
> trying to program my own system tester using MetaStock's Expert Adviser
> and the Indicator Builder programming language. However, due to the
> archirecture of the MetaStock programming language it is impossible to
> build a system tester for the case that the exit criteria is based
> upon the entry criteria. (I have MetaStock support folks looking at
> this, however, I am not optimistic.)
> 
> Here is a sketch of the trade I described above.
> 
>                      HIGH |
>                           | <--- CLOSE + 1/2
>                           |
>                 _|_       |
>         CLOSE  |   |     _|_
>                |   |    |   |
>                |   |    |___|
>                |___|      |       _|_
>                  |       (2)     |   |
>                 (1)              |   |
>                                  |___|
>                                    |
>                                   (3)
> 
> a) A trade is entered at the CLOSE of bar (1). The exit target price
>    is CLOSE + 1/2
> 
> b) The HIGH of bar (2) exceeds the value of CLOSE + 1/2. The trade
>    is exited and counted as profitable (profit of 1/2 point).
> 
> c) The MetaStock System Tester looks only at the closing prices of
>    bars (2) and (3). The closing prices of bars (2) and (3) do not
>    exceed CLOSE + 1/2. If the close of bar (3) triggers a STOP the
>    trade is exited and accounted for as a loss.
> 
> One would not think that doing this should be very difficult, but so
> far I have found it to be impossible.
> 
> Thanks,
> Regards,
> Tim Kruzel