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

Re: GEN : How does TradeStation sequence system code?



PureBytes Links

Trading Reference Links

Troutman, Defender of Sticks wrote:

> On the day a position is taken, if the close of the market is some 
> fixed distance away I want to add an extra reversal stop order that 
> stays at the one fixed price in addition to the normal reversal 
> orders that are generated, OCO.

You cannot cancel orders in TS, so OCO is impossible.  An order is always active until it is 
filled, or until it is replaced by another order in the same direction (long or short).  However, if 
daytrading and set to exit all positions at close, this cancels all open orders..  Also, remember 
that positions are reversed automatically.  For example, if the system is long and a sell order is 
executed, you do NOT want to sell 2 contracts in order to go short, even though that is what you 
would do in the real world.

All code is executed after the close of every bar, with the exception of lines beginning with 
"input:" or "var:", or those defining a DLL function.  However, you do not need to worry about this
as the orders will be handled for you by TS.

Let's say you want to buy on a stop at yesterdays' close + 10 points, or sell on a stop at that 
close - 10 points.  However, if it goes up 20 points from the close you want to reverse to short.
Here is code to do that.....

buy (close + 10 points) stop;
sell (close - 10 points) stop;
sell (close + 20 points) limit;

if it goes up 10 points it will go long.  If it then drops 20 points it will reverse to short.  Both of 
those orders will have then expired because they have been filled.  The limit order cannot 
execute unless you set the system up to trade more than one contract.  If the system goes long 
on the +10 point stop, and the market goes up another 10 points, it will reverse to short on the 
limit order.  Since it is then short, the order 10 points below the market cannot be executed.

Is this something like what you want to do?

Bob Young