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

RE: BUY/SELL Trigger question



PureBytes Links

Trading Reference Links

Thanks Dave, I've been out for a while.   I'll work on trying this with my
system.

ddefina@xxxxxxxxxxxx

-----Original Message-----
From: owner-metastock@xxxxxxxxxxxxx [mailto:owner-metastock@xxxxxxxxxxxxx]On
Behalf Of Dave Nadeau
Sent: Jan 19, 2001 11:05 PM
To: metastock@xxxxxxxxxxxxx
Subject: RE: BUY/SELL Trigger question

Dave and Bill,

The short answer to this question is yes and no:  Yes this can be programmed
in MetaStock's Formula Language, and no, I don't believe this can be done in
the system tester.

I often use the system tester to look at "pieces" of my trades, like Al's
recent message about testing an entry with a fixed 3 day exit.  Once I find
all of the pieces that I want, I will usually build several custom
indicators including an equity line that will take the place of the system
tester.

More specifically to your question:  To first get a custom indicator to show
whether you are long or short is your starting point.  If you are basing a
system off of an indicator's action, then it's a fairly straight forward
matter.

I will use an example of a stochastic.  The fast stochastic crosses the slow
stochastic(or trigger).

FAST:=Stoch(5,3);
SLOW:=Mov(FAST,3,S);
{Defines your Signal and Trigger lines respectively}

{Long Signal}
LNG:=Cross(FAST,SLOW);
{Short Signal, note the sign convention that I'm establishing}
SHT:=-1*Cross(SLOW,FAST);

{Now here's the function which identifies if you are long or short}
POSITION:=If(BarsSince(LNG=1)<=BarsSince(SHT=-1),1,-1);

This is the fairly simple stop and reverse case.  You can add some
complexity to this by defining some exit condition for the short or long
position.  In keeping with the BarsSince() methodology, you would just add
in some additional IF() statements which return zero instead of +1 or -1.

Now that you have the POSITION function created in your custom formula, you
can haul out the very useful "ValueWhen() function.  For example, to find
the price that you entered your trade, you could use something like ....
LONGENTRY:=ValueWhen(1,Cross(POSITION,0.5),OPEN or CLOSE); and similarly for
a SHORTENTRY.

This last ValueWhen assignment operates off of the action of the POSITION
indicator that you have built previously.  When your system goes long,
POSITION goes to +1, then when you stop and reverse, it goes to -1.  With
some other exits, it will go to zero in between.

Now that I think about this, here is a point where you can use the system
tester.  Once you have all of the above defined, go to the System Tester and
under the Long Entry tab, you can enter

FmlVar("Your custom formula name","POSITION")=1 AND Ref(FmlVar("Your custom
formula name","POSITION"),-1)<>1

Your Long Exit tab would be
C>=FmlVar("Your custom formula name","LONGENTRY")+Stdev(C,9)

and likewise for the short side.

There are some drawbacks to the above.  First of all, you can see that you
might have another long signal that the System Tester would miss if you exit
early with a quick profit and the POSITION indicator hasn't reset down to
zero or -1.  Also, you have to enter or exit on the OPEN or CLOSE of the bar
using the System Tester.

If you wanted to take this a step further, you could continue with your
Custom Indicator and create your exits like we created the LNG and SHT
positions.  Something like
LNGEXT:=C>=LONGENTRY+Stdev(C,9);

Then if LGNEXT=1, you'd exit on the OPEN or CLOSE.

Because your exits are built from a value triggered by the original POSITION
indicator, it would be recursive and very problematic if you used these
variable assignments (i.e. LNGEXT) in your POSITION indicator.  How to solve
this?  Just create a second indicator made up of the long exits.  Something
like If(BarsSince(LNGEXT=1)<=BarsSince(LNG+SHT<>0),-1,0).  So you can see
that when you add this indicator which has triggered an exit to the POSITION
indicator which is still showing long, a +1 and a -1 will give you a
resultant of zero--i.e. no position.  Again, similar logic for the short
side.

The resultant sum of the two indicators, say it's called TOT_POSITION could
be used directly in the System Tester or you could take the next step and
create an equity curve in the custom indicator and run an Exploration to
give you performance results over a whole portfolio of stocks.

I hope this answers your question and wasn't tooooooooo long winded.

Dave Nadeau
Fort Collins, CO

-----Original Message-----
From: owner-metastock@xxxxxxxxxxxxx [mailto:owner-metastock@xxxxxxxxxxxxx]On
Behalf Of Bill Irwin
Sent: Friday, January 12, 2001 1:34 PM
To: metastock@xxxxxxxxxxxxxxxxxx
Subject: RE: BUY/SELL Trigger question


Excellent idea Dave!  I'll eagerly await the suggestions.  It can be a
battle developing a system which doesn't require constant babysitting while
you watch how it works on each stock.

Bill
  -----Original Message-----
  From: owner-metastock@xxxxxxxxxxxxx
[mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of David DeFina
  Sent: Wednesday, January 10, 2001 11:33 AM
  To: metastock@xxxxxxxxxxxxx
  Subject: BUY/SELL Trigger question



  Is there a way to program the system tester to know when a trade is
currently long or short, and to base decisions based on that trades entry
price?  I want to program an exit point to equal the "entry price" + say the
standard deviation of the previous 9 bars.  This would give you say 40 entry
price + 6 dollars standard deviation for an exit price of $46.



  My system, which works quite well, uses a profit stop of 12% to exit
trades.   This obviously works only on highly volatile stocks.  I would like
to have the system automatically determine achievable profit goals based on
historical volatility of the stock, in order to have it work on stocks with
varying betas.



  Is there a way to program profit stops that are dependant on stock
volatility, and avoid using arbitrary points or percentages in the profit
stop tab?



  Thanks,

  David DeFina

  ddefina@xxxxxxxxxxxx


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com