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

Re: I can not figure out how to do multiple exits from one signal


  • To: "Bengtsson, Mats" <mats.bengtsson@xxxxxxxxxxxx>
  • Subject: Re: I can not figure out how to do multiple exits from one signal
  • From: "Phil Lane" <patterntrader@xxxxxxxxxx>
  • Date: Wed, 10 Nov 1999 05:57:23 -0800
  • In-reply-to: <8F51562044CFD111B27B00805FE222E97ED889@xxxxx>

PureBytes Links

Trading Reference Links

mmm... on closer examination I see you only have one exitlong statement. It
gets activated only once, the FIRST time the conditions are satisfied. Just
the way TS works.

You'll need a separate exit statement for each exit you want to do in a
given trade.

If you know the max number of exits you'll have, you can setup this many
exit statements. in the code.

Also set up a counter initialized to the total number of contracts bought.
Define some variable MP=MarketPosition. Check for MP<>MP[1] every day, and
if true (that means you sold something) then decrement the counter.

preface each exit statement with "If counter =3 (or whatever - count the
numbers down from the starting point) to allow only one to activate at a
time.

let me know how it goes :-)


----- Original Message -----
From: Bengtsson, Mats <mats.bengtsson@xxxxxxxxxxxx>
To: Phil Lane <patterntrader@xxxxxxxxxx>
Sent: Tuesday, November 09, 1999 2:34 PM
Subject: RE: I can not figure out how to do multiple exits from one signal


> Tried it, and it did not help. All Code is below:
> Inputs: DateToBuy(990101),NumberOfShares(200),PriceToBuyAt(200),
>         ATRLength(10);
>
> if Date=juliantodate(BusinessDays(datetojulian(dateToBuy),2,-1)) then
> Buy("PortfolioBuy") NumberOfShares contracts Next bar at
> PriceToBuyAt stop;
>
> if (currentcontracts>0) then Begin
>    if (close < (PriceToBuyAt*0.91)) then Begin
>   ExitLong 1 shares total from entry ("PortfolioBuy") next bar at
> market ;
>   commentary("below");
> End;
> End;
>
> It still only sell once.
>
> > -----Original Message-----
> > From: Phil Lane [mailto:patterntrader@xxxxxxxxxx]
> > Sent: Tuesday, November 09, 1999 3:50 PM
> > To: Bengtsson, Mats
> > Subject: Re: I can not figure out how to do multiple exits from one
> > signal
> >
> >
> > Hi,
> > you need to use the keyword "total" and things will work
> > fine. Example:
> >
> > if whatever then sell currentcontracts/2 contracts TOTAL from
> > entry myentry;
> >
> > good luck,
> > Phil
> > ----- Original Message -----
> > From: Bengtsson, Mats <mats.bengtsson@xxxxxxxxxxxx>
> > To: <omega-list@xxxxxxxxxx>
> > Sent: Monday, November 08, 1999 10:19 PM
> > Subject: RE: I can not figure out how to do multiple exits
> > from one signal
> >
> >
> > > Thank you for your reply. Is there a difference within Tradestation
> > between
> > > shares and contracts? I buy one single contract with a lot
> > of shares in it
> > > at one single time (I thought that was the same thing). It
> > is those shares
> > I
> > > want to sell at different times. My code, which sells only
> > once (saying
> > > there are 199 shares left) is below. My guess is that there
> > is some rule
> > in
> > > TS2000 that disallows "pyramiding exits" from the same sell
> > signal, mening
> > > that I  will have to enter 200 different but exactly the
> > same signals to
> > get
> > > this kind of testing to work. On the other hand, then I
> > would need to
> > figure
> > > out a way for them not to operate on the same date as each
> > other, that is
> > > more or less solve a "pyramidign exit pussle".
> > >
> > > This sounds as a severe limitation for backtesting.
> > >
> > > Inputs: DateToBuy(990101),NumberOfShares(200),PriceToBuyAt(200),
> > >         ATRLength(10);
> > >
> > > if
> > Date=juliantodate(BusinessDays(datetojulian(dateToBuy),2,-1)) then
> > > Buy("PortfolioBuy") NumberOfShares contracts Next bar at
> > > PriceToBuyAt stop;
> > >
> > > if (CurrentContracts>0) then Begin
> > >    if (close < (PriceToBuyAt*0.9)) then
> > >   ExitLong 1 shares next bar at market;
> > > End;
> > >
> > > >  When I was testing some systems in a similar way, I used the
> > > > "@CurrentContracts" function. I was using 100 share contracts so I
> > > > just multiplied the function by 100 on exiting.
> > > >
> > > > Example:
> > > >
> > > > NumberOpen = @CurrentContracts;
> > > > ...
> > > > ...
> > > > ...
> > > > ...
> > > > IF Condition8 AND
> > > > Condition10 THEN
> > > > ExitLong (NumberOpen*100) shares at Open;
> > > >
> > > > I had two conditions that, when fulfilled, would sell off
> > 100 shares
> > > > each time until the NumberOpen fell to zero. I just used another
> > > > IF...THEN statement to check for NumberOpen to be zero, then it
> > > > would stop the system.
> > > >
> > > > Good Luck,
> > > >
> > > > -- Patrick
> > > >
> > > > **************************************************************
> > > > **********
> > > > > Guess it is possible?
> > > > >
> > > > > What I would like to do is to buy say for example 200
> > > > shares at one point,
> > > > > and every time a certain condition is true sell one of
> > > > those shares.
> > > > >
> > > > > I can not figure out how to do it. Selling one share is not
> > > > the problem,
> > > > > getting my signal to sell until number of shares is zero is
> > > > the problem.
> > > > >
> > > > > What am I missing?
> > > > >
> > > > > --- Mats ---
> > > > > Cap Gemini Sverige AB
> > > > > European company of the year 1999
> > > >
> > > >
> > >
> > >
> >
>