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

Re: FAQ and System tester question



PureBytes Links

Trading Reference Links

Due to the limitations of the system tester, I have used a graphical approach of
system testing. I gave an example of this in  my post :-
3d Aug 98 subject ' System test w/o "re-investment": How? and "System Testing"'

To save you the search, I have listed below the relevant code as well as attaching
the .dta files to enable you to import this code...
(The .gif displays the result obtained in this example and the .dta files contain
the indicator and expert code)

Although this example does not address your specific requirement, it is provided
as an example of what can be accomplished using a graphical approach to system
testing.

Using this approach, you can use any rules you care to define to determine your
buy and sell criteria and prices. The indicator can display your resultant equity
line and the expert can be used to add color to your bars and add buy and sell
arrows.

************************************************************************

{example of using the system indicator to demonstrate the feasibility of a given
buy and sell strategy}

{Note this example uses 99% of the daily high as the sell value ... because we may
not necessarily know when the high has occurred we may not be able to achieve this
price ... but then this is purely an example to demonstrate the approach of using
the indicator builder}

buycap:=10000;{capital}
mov3:=Ref(Mov(C,3,S),-1);
{buy and sellpulse occur each time buy or sell condition is satisfied}
buypulse:=Cross(C,mov3);
sellpulse:=Cross(H>Ref(C,-1),0.5);
{long indicates whether we are long or out of the market}
long:=If(buypulse ,1,
      If(sellpulse,0,PREVIOUS));
{buy and sellpulse1 occur only at the start and end of going long}
buypulse1:=buypulse AND
           Ref(long,-1)=0 AND
           long=1;
sellpulse1:=sellpulse AND
           Ref(long,-1)=1 AND
           long=0;
buyval:=ValueWhen(1,buypulse1,C);
{sell value is 99% of daily high}
trailstop:=0.01;
sellval:=ValueWhen(1,sellpulse1,H*(1-trailstop));
buyqty:=Int(buycap/buyval);
profit:=ValueWhen(1,sellpulse1,
        (sellval-buyval)*buyqty);
cumprofit:=If(sellpulse1,PREVIOUS+profit,
         PREVIOUS);
buycap;
cumprofit;
buyqty*10;
0;
***********************************************************************
expert ... highlight as green (long) bars by picking up "long" from "m015 example"

highlight (green long bars) ... FmlVar("m015 example","long")

***********************************************************************
expert ... add buy and sell signals by picking up "buypulse1" and "sellpulse1"
from "m015 example"

symbols (buy arrow)  ... FmlVar("m015 example","buypulse1")

symbols (sell arrow) ... FmlVar("m015 example","buypulse1")
*****************************************************************************

Regards ... Martin

UG wrote:

> First off, is there a FAQ for metastock OTHER than any on Equis' site?
>
> Secondly, I was wondering if there were an option on the system tester to
> enter a long position on a stop or limit.  Something like:
>
> If the 9 day MA crosses over the 18 day MA, go long tomorrow at today's high +
> 1/16 on a stop.  (And also with limits.)
>
> Supercharts can do this.
>
> The only way I can think of is to check the condition for YESTERDAY, and add
> the qualifier that the high actually made it over whatever price you were
> setting the stop on.  Something like:
>
> Go long on: cross(Ref(Mov(C, 9, S), -1), Ref(Mov(C, 18, S), -1)) AND
>             Hi > Ref(Hi, -1)
>
> As an aside, on the "enter" rules (long OR short), at what price does it "buy"
> or "sell"?
>
> --
> ========================================================================
> I bet the one legend that keeps recurring throughout history, in every
> culture, is the story of Popeye.
> http://www.unixgeek.com/cgi-bin/motd.pl - PGP email preferred



Attachment Converted: "c:\eudora\attach\wow example1.gif"

Attachment Converted: "c:\eudora\attach\Ms65form1.dta"

Attachment Converted: "c:\eudora\attach\Ms65expt1.dta"