[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



PureBytes Links

Trading Reference Links

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
> 
>