Hitting Limitations with Tradestation

Discussion in 'Trading Software' started by pedro01, Jan 3, 2009.

  1. pedro01

    pedro01

    Hi All

    I have gotten to the point in my trading strategy automation where it feels as if Tradestation is less of a fit that it should be and I am wondering if this is just me being dumb or if TS isn't the tool for me.

    So a little on my strategy (without spilling the beans).

    part 1 - a radar screen with a list of stocks being rated (feeding info to global vars) as well as calculating position size for each stock considering my basket size, my account size, risk per trade & some stock specific items
    part 2 - a mutli time frame look at an index which gives me buy & sell signals

    When I get a buy or sell signal, I go to my global vars, look at my ratings & then place buys or sells on the radar screen stocks. I also set target prices for my stop loss & scale-out of a profitable trade.

    Global variables are slightly painful but if you handle all that in functions you can keep it consistent & away from the body of your code. What is a pain is the fact that you can't use strategies for this kind of system as you can't attach a strategy to radar screen, nor can you trade a basket of stocks in a strategy from a single chart. Note that I wouldn't want my strategy on the radar screen as I want my trade issued based on the action of the index, not wait for the next tick on the symbol to issue my order. So, I am using order macros and I am having to do the following:

    On placing a trade
    Store number of shares traded in GVs, then keep checking for fills. As you get filled, place stop loss orders at the appropriate levels as well as storing the average price.

    On scaling out
    Cancel your stop loss order
    Place a sell order for 75% of your position
    Put back the stop loss on the remaining 25%

    It's probably easier to explain this if I show an example of the trades:

    Initial Buy : .PlaceOrder "Action='Buy', Account='SIMxxxxxxM', Symbol='MNT', SymbolCategory='Equity', OrderType='Market', Quantity=560, Duration='Day'"
    stop loss: .PlaceOrder "Action='Sell', Account='SIMxxxxxxM', Symbol='MNT', SymbolCategory='Equity', OrderType='Stop Market', StopPrice=30.43, Quantity=560, Duration='Day'"

    So I have my buy & I have my stop loss. Now let's say I'm really lucky & my target gets hit - maybe 20-30 minutes later. What I want to do now (and you will recognise this) is to sell 75% of my position and put a stop loss on the remaining 25% at entry +2c. The problem is that I can't sell 75% of my position because I have an outstanding sell order on the stock (the stop loss).

    So - as far as I know, I need to cancel the stop loss order, then issue the sell order for 75% of the position and then put back the stop loss on the remaining amount.

    Cancel Stop Loss : .CancelAllOrdersSymbolAcc ount MNT,SIMxxxxxxM
    Scale Out : .PlaceOrder "Action='Sell', Account='SIMxxxxxxM', Symbol='MNT', SymbolCategory='Equity', OrderType='Market', Quantity=420, Duration='Day'"
    New stop loss : .PlaceOrder "Action='Sell', Account='SIMxxxxxxM', Symbol='MNT', SymbolCategory='Equity', OrderType='Stop Market', StopPrice=30.79, Quantity=140, Duration='Day'"

    This occasionally fails because I send the orders to the TS servers using the PlaceOrder macro but the cancel stop loss has sometimes not yet been processed by the time it gets the scale out. I can't seem to see any order type that will let me do this.

    I could actually send the cancel stop loss and then wait for it to be processed but I don't see any way to either see if the stop loss is still there OR get confirmation it has been removed. Without either of these, my only option is an arbritrary pause in the code of let's say 10 seconds to ensure the cancel stop loss has plenty of time to get processed. That's not something I want to do though - who wants to wait any amount of time to get out ?

    Anyway - I'm a bit stumped and fearing the worst !

    Any ideas

    Cheers

    Pete