Place Multiple-Leg Trades in ThinkOrSwim from Excel with MarketXLS
The TradeMultiLegThinkOrSwim function allows you to configure and send multi-leg option orders directly from Excel to ThinkOrSwim. With this function, you can save time, avoid manual data entry mistakes, and conveniently manage everything in one spreadsheet. It supports up to four leg definitions, validating your inputs in real time to help ensure they meet multi-leg order requirements.
Why Use This Function?
- Streamlines multi-leg option setup directly within Excel, minimizing data re-entry.
- Ensures consistency in underlying symbols and coherent order-side/quantity checks.
- Reduces potential typos and saves time compared to manual ticket entry.
- Allows integration with your existing MarketXLS-based spreadsheets, data analysis, or trading logs.
- Ideal for spread trades, iron condors, straddles/strangles, and other multi-leg strategies where multiple options must share the same underlying.
How to Use in Excel
Use the following syntax in any Excel cell, ensuring you have the MarketXLS add-in installed and licensed:
=TradeMultiLegThinkOrSwim(OrderType, Price, SymbolOption1, Quantity1, OrderSide1, [SymbolOption2], [Quantity2], [OrderSide2], [SymbolOption3], [Quantity3], [OrderSide3], [SymbolOption4], [Quantity4], [OrderSide4])
• Type this function into a cell just as you see above.
• Required parameters must be provided; optional ones can be left out if fewer than four legs are needed.
• At least two legs must be provided (SymbolOption1 plus SymbolOption2) to execute a multi-leg trade.
Parameters Explained
Parameter | Description | Example Values | Notes |
---|---|---|---|
OrderType | The type of trade order. | "MARKET", "LIMIT" | In the backend, only "MARKET" and "LIMIT" are strictly recognized for final processing. In the front-end, “CREDIT” or “DEBIT” can be entered but must include a valid Price > 0. |
Price | The limit or reference price (if needed). | 1.25, 0.50, 2.00 | If OrderType is "LIMIT", this number is used in the TOS routing. For “MARKET” orders, any numeric placeholder (e.g., 0) is acceptable but not strictly necessary. |
SymbolOption1 | The first option symbol string (required) including underlying, dates, strike, call/put. | "@TSLA_100_03MAY23_C_500_... (etc.)" | Must pass validation (length, format). Appears in the final TOS string. This leg is required for any multi-leg trade. |
Quantity1 | The quantity of contracts for leg 1. | 1, 5, 10 | Must be > 0. A negative quantity or invalid format returns an error. |
OrderSide1 | Whether the first leg is buy or sell. | "BUY" or "SELL" | Must parse to a valid MarketXLS side enumeration. Invalid sides generate an error message. |
SymbolOption2 | The second option symbol (optional), required if you want at least two legs. | Same format as SymbolOption1 | If non-empty, quantity and side must also be provided. Otherwise, pass empty strings/zeros (or omit in the formula if your Excel version allows). |
Quantity2 | The quantity of contracts for leg 2. | 2, 4 | Must be > 0 if SymbolOption2 is used. Otherwise set to 0 or omit. |
OrderSide2 | Whether the second leg is buy or sell. | "BUY" or "SELL" | Must be valid only if SymbolOption2 is not empty. |
SymbolOption3 | The third option symbol (optional). | Same format as SymbolOption1 | Provide if you have a 3rd leg, else leave empty. |
Quantity3 | The quantity of contracts for leg 3. | 1, 3 | Must be > 0 if SymbolOption3 is used. |
OrderSide3 | Whether the third leg is buy or sell. | "BUY" or "SELL" | Must be valid only if SymbolOption3 is not empty. |
SymbolOption4 | The fourth option symbol (optional). | Same format as SymbolOption1 | Provide if you have a 4th leg, else leave empty. |
Quantity4 | The quantity of contracts for leg 4. | 1, 2 | Must be > 0 if SymbolOption4 is used. |
OrderSide4 | Whether the fourth leg is buy or sell. | "BUY" or "SELL" | Must be valid only if SymbolOption4 is not empty. |
Notes:
• All legs must share the same underlying ticker symbol.
• The backend enforces a minimum of two valid option legs before it can create a TOS multi-leg order.
• When specifying optional legs, you must fully specify SymbolOption, Quantity, and OrderSide. Otherwise, leave them blank or zero.
Example Usage
Basic Examples
-
Two-Leg Debit Spread (Limit Order)
In this scenario, you want to buy one call option and sell another call option of the same underlying.
=TradeMultiLegThinkOrSwim("LIMIT", 2.50, "@AAPL_100_05MAY23_C_160", 1, "BUY", "@AAPL_100_05MAY23_C_170", 1, "SELL")• OrderType = "LIMIT"
• Price = 2.50 (the debit limit price)
• First Leg: Buy 1 AAPL 05MAY23 160C
• Second Leg: Sell 1 AAPL 05MAY23 170C -
Two-Leg Market Order (Straddle)
Suppose you want to buy a call and a put at the market price.
=TradeMultiLegThinkOrSwim("MARKET", 0, "@MSFT_100_10JUN23_C_300", 5, "BUY", "@MSFT_100_10JUN23_P_300", 5, "BUY")• OrderType = "MARKET"
• Price = 0 (placeholder)
• First Leg: MSFT 10JUN23 300C (Buy 5)
• Second Leg: MSFT 10JUN23 300P (Buy 5)
Advanced Scenarios
-
Three-Leg Spread (Butterfly Example)
Let’s say you want to set up a butterfly spread on SPY. You’ve decided on:- BUY 1 SPY 12MAY23 400C
- SELL 2 SPY 12MAY23 405C
- BUY 1 SPY 12MAY23 410C
You can do:
=TradeMultiLegThinkOrSwim("LIMIT", 1.10, "@SPY_100_12MAY23_C_400", 1, "BUY", "@SPY_100_12MAY23_C_405", 2, "SELL", "@SPY_100_12MAY23_C_410", 1, "BUY") -
Four-Leg Iron Condor
For an iron condor on QQQ, your final combination might look like:- SELL 1 QQQ 19MAY23 300C
- BUY 1 QQQ 19MAY23 310C
- SELL 1 QQQ 19MAY23 270P
- BUY 1 QQQ 19MAY23 260P
=TradeMultiLegThinkOrSwim("LIMIT", 1.25, "@QQQ_100_19MAY23_C_300", 1, "SELL", "@QQQ_100_19MAY23_C_310", 1, "BUY", "@QQQ_100_19MAY23_P_270", 1, "SELL", "@QQQ_100_19MAY23_P_260", 1, "BUY")
-
Integration with Other Excel Features
Combine real-time market data or calculations (e.g., desired spread price, custom Greeks, or probability of profit) directly into the Price parameter. For instance, if cell B2 calculates your target spread entry price dynamically, you could do:
=TradeMultiLegThinkOrSwim("LIMIT", B2, "@AMZN_100_09JUN23_C_120", 2, "BUY", "@AMZN_100_09JUN23_C_130", 2, "SELL")
Common Questions and Troubleshooting
• “Please enter at least 2 legs when using this function”: Occurs if you only provide one set of option inputs. You must have at least SymbolOption1 and SymbolOption2 filled.
• “All legs should have the same underlying”: Make sure every specified option symbol references the same underlying ticker symbol (e.g., AAPL, MSFT, etc.).
• “Please enter a valid trade type”: Only "MARKET" or "LIMIT" are supported in the final TOS backend route.
• “Order side is invalid. Please check your inputs.”: Check your “BUY”/“SELL” parameter.
• “Symbol option is required. Please check your inputs.”: Confirm your option symbol is properly formatted and not left blank if you’re including that leg.
• “Price has an invalid format. Please check your inputs.”: Ensure that the cell or value you’re referencing for Price is a valid number.
• “Quantity has an invalid format. Please check your inputs.”: Be sure you’re passing an integer or a cell containing a numeric value.
With these guidelines, you can harness the power of multi-leg trading in ThinkOrSwim efficiently using the MarketXLS Excel add-in. Keep your trading data in one place, reduce manual duplication, and make advanced options strategies more accessible directly within your spreadsheets.