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

Re: Avoid reentering



PureBytes Links

Trading Reference Links

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