Trade options on TradeStation: open vs close
A stock order is a buy or a sell. An option order also has to say whether it opens a position or closes one. TradeStation wants one of four actions: buy to open, sell to open, buy to close, or sell to close. Your alert only says b=buy or b=sell, so Autoview has to pick the rest. This guide shows how it picks, and the one parameter that decides it.
We wrote this from the Autoview integrations code that runs on our servers today. We read the code; we did not run these lines live or on the TradeStation Simulator. Test yours with d=1 and then on a Simulated account before you trade real contracts.
The rule: close=1 means close, anything else means open
When the symbol is an option, Autoview builds the action from b= and close=. That covers stock, index, futures and currency options.
| Your line | What TradeStation receives |
|---|---|
b=buy | Buy to open |
b=sell | Sell to open |
b=buy close=1 | Buy to close |
b=sell close=1 | Sell to close |
On a stock or a futures contract, close= changes nothing here. TradeStation gets a plain buy or sell.
The mistake: a plain sell to get out
Say you bought a call with b=buy q=1. Later your strategy fires its exit alert, and the alert says b=sell q=1. Without close=1, Autoview sends that as sell to open. You do not exit the call. You write a new one. If your account is not approved to write options, TradeStation rejects the order and you are still holding the call you meant to sell.
The same goes for a protective stop. A stop line with px= or fpx= and no close=1 is a sell-to-open stop. Put close=1 on every exit line, stops included.
s=<TradeStation option symbol> b=buy q=1
s=<TradeStation option symbol> b=sell q=1 close=1
The first line buys one contract to open. The second sells one contract to close. If you hold a short option, mirror it: b=sell q=1 opens the short, b=buy q=1 close=1 buys it back.
Closing with c=position
c=position also sends a closing order. It looks up your open positions on the symbol, flips the side, and sets close=1 for you, as long as you leave opposite= at its default and do not send close= yourself. Add b= to pick which side to close: b=long (or b=buy) closes a long option, b=short closes a short one. Without q=, it closes the whole position.
s=<TradeStation option symbol> c=position b=long
One thing we could not confirm from the code: that TradeStation reports option positions under the same symbol you send. If it does not, c=position logs "No positions found." and closes nothing. Try it on the Simulator before you depend on it. The explicit b=sell close=1 line does not need a position lookup.
The symbol
Use TradeStation's own symbol for the contract, copied from TradeStation. Autoview asks TradeStation to look the symbol up, and if TradeStation does not return it under the same name, the line stops with an unknown symbol error. We have not checked how TradingView's option tickers map to TradeStation's, so do not assume the ticker from your chart will work. A d=1 run does the lookup, so it catches a bad symbol before anything is sent.
Size in contracts
Send a whole number of contracts on every option line, such as q=1. Do not leave q= off. The default is q=100%, and we have not verified how percent sizing converts on TradeStation options. A contract usually covers 100 shares, and we did not find that multiplier in the sizing code.
Check it with a dry run
Add d=1 to the line. Autoview looks up the symbol, builds the order, and writes it to your log without sending it. The order it builds carries the TradeStation action, so you can check that your exit reads sell to close and not sell to open. The log guide shows where to look. Then run the same lines on a TradeStation Simulated account for a real fill.
New to TradeStation on Autoview? Start with getting started with TradeStation. For how closes work on other exchanges, see close or reverse on an opposite signal. If an order never shows up, TradeStation not taking orders walks through each failure path.