PureBytes Links
Trading Reference Links
|
Ray Gurke pointed out that I misunderstood the original problem; he
wanted to keep from exiting if the entry signal was still good, not keep
from entering a new contract with a new entry signal.
The approach is still the same. You have an entry signal. Just as you
would check marketposition against your entry signal to determine if a
new position should be entered, you would check your entry signal
against your exit signal to determine if a position should be exited.
Example:
sig = ShortAverage - LongAverage;
{entry}
if marketposition <= 0 and sig > 0 then buy;
if marketposition >= 0 and sig < 0 then sell;
{exit}
if [exit long condition] and marketposition > 0 and sig <= 0 then ExitLong;
if [exit short condition] and marketposition < 0 and sig >= 0 then ExitShort;
...where the exit conditions are something you have to create.
-Alex
>To: massimiliano.scorpio@xxxxxxxxxxxx (Scorpio Massimiliano)
>Date: Tue, 7 Jan 2003 08:45:05 -0800 (PST)
>Cc: omega-list@xxxxxxxxxx
>From: alex@xxxxxxxxxxxxxx (Alex Matulich)
>
>Max wrote:
>>If the short moving average is above the long one I buy the market, the
>>opposite for selling.
>>If I want to use a trailing stop or profit taking and I exit from the
>>market, if the condition is still true, I immediatly re-enter in the same
>>position that I just closed.
>
>And you want to avoid this. It's easy, just use the marketposition
>variable. I'll assume the names ShortAverage and LongAverage for your
>moving averages:
>
>if marketposition <= 0 and ShortAverage>LongAverage then buy;
>if marketposition >= 0 and ShortAverage<LongAverage then sell;
>
>marketposition is a TS internal value; it is +1 if you have a long
>position already open, -1 if you have a short position already open,
>and 0 if you have no open positions.
>
>Therefore the two "if" statements above will enter the market ONLY
>when you have no open positions, or when your entry signal is
>opposite in direction to your open position.
--
,|___ Alex Matulich -- alex@xxxxxxxxxxxxxx
// +__> Director of Research and Development
// \
// __) Unicorn Research Corporation -- http://unicorn.us.com
|