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

Multiple partial exits in TS2000i



PureBytes Links

Trading Reference Links

Hi everybody,

I seem to be having difficulties getting TS2000i to execute multiple parital
liquidations for me for a trading strategy I've written. My system begins
with an initial amount of capital, and has a position sizing algorithm to
compute the number of contracts to trade. The system is supposed to reduce
the number of contracts I'm holding if the open risk (ie., the potential
dollar amount lost if we were to be stopped out) exceeds my threshold -
MaxPctOpenRisk. Here's a sample of the code in question:

{***************************************************************************
***********************}

Inputs: InitCapital(100000),MaxPctOpenRisk(0.06);
Vars: openEquity(0),curStopPrice(0),price(0);

openEquity = InitCapital + GrossProfit + GrossLoss;
if (MarketPosition > 0) then
	openEquity = (Close - AvgEntryPrice) * CurrentContracts * BigPointValue +
openEquity;
else
	openEquity = (AvgEntryPrice - Close) * CurrentContracts * BigPointValue +
openEquity;

{
	o curStopPrice is my trailing stop for the entire position.
	o openEquity is the current equity, including the P&L from the currently
open trade.
}


if (MarketPosition > 0) then
begin
	price = openEquity * MaxPctOpenRisk / (BigPointValue * CurrentContracts) +
curStopPrice;

	ExitLong("LXSRX") 1 contracts next bar at price limit; {*** Partial
liquidation ***}
end;

{***************************************************************************
***********************}

Unfortunately, TS performs the first partial liquidation trade, but the rule
doesn't fire again until the entire position is liquidated and a new long is
put on. Is there some limitation to TS2000i that prevents it from refiring
the same partial exit rule, or am I missing something?


Any help would be greatly appreciated,

Milton Smith