TradingView – Long Straddle Options Strategy (Automated Trading)
Build a Long Straddle options strategy in TradingView and send both legs to your broker automatically.
This post shows how to build a Long Straddle options strategy in TradingView using Pine Script, then send the buy orders to your broker automatically through AutoTrader Web. TradingView fires the alert, and AutoTrader Web works out the call and put option contracts and places both orders. The strategy is for learning and demonstration only. We do not promise any returns.
Introduction
In this post we build a Long Straddle options strategy on TradingView and automate it using AutoTrader Web. AutoTrader Web works with leading Indian stock brokers.
The strategy is for learning and demonstration purposes only. We do not promise any returns.
What is a Long Straddle?
A long straddle is an options strategy where you buy a call and a put on the same underlying asset, with the same expiry date and the same strike price.
This strategy works well when the underlying asset makes a big move in any direction:
- If the price moves up, you gain on the call option.
- If the price moves down, you gain on the put option.
- If the market does not move much, your maximum loss is the total premium you paid for the call and the put.
We use a moving average indicator to spot a possible big move. Because the strategy needs a large move to be profitable, you should consider using higher values for the short-term and long-term moving average periods.
TradingView does not support option charts. So you run this strategy on the underlying asset. The asset can be a stock, an index, or their future contracts. When a signal fires, AutoTrader Web works out the option contracts and places them for you.
Exit strategy: For now we assume the time needed for a big move is long, so you exit the positions manually. You can also add a beta risk-limit exit — see Optional: add a risk limit at the end.
Before you start
You need three things:
- An AutoTrader Web account
- A TradingView account
- A trading account with any of the supported brokers
Setup
- Open a TradingView account (if you do not have one).
- Register on AutoTrader Web.
- Add your trading account.
Step 1: Create the strategy
- Go to TradingView.
- Click the Chart option on the top.
- Choose the stock or derivative you want to work on by selecting the Symbol (you can see the symbol on the LEFT TOP section of the chart screen). You can select any symbol (a stock, or a derivative on the Indian stock exchanges).
- Click on Pine Editor (found on the BOTTOM section of the chart screen).
- Change the name from “Untitled Script” to “Long Straddle”.
- Remove the existing content from the script and add the strategy code below.
- Feel free to make any changes of your choice.
Note: This strategy uses our free, open-source Pine library, StocksDeveloperAlerts. It builds the alert message for you, so you never type the alert format by hand. AutoTrader Web works out the exact option strike and expiry contract on its side — there is no strike maths in your script. Always use the latest version by keeping the version number in the import line (line 2) up to date.
//@version=6
import StocksDeveloper/StocksDeveloperAlerts/1 as atw
strategy("Long Straddle", overlay = true, calc_on_every_tick = true)
// A long straddle buys a call and a put at the same at-the-money strike. It aims
// to profit from a big move in either direction, so it is essentially a market
// or direction-neutral strategy. Here we use a moving-average crossover only to
// spot a possible big move — you can replace it with any signal you like.
// ----- Account -----
i_account = input.string("ACC_NICKNAME", "Account or Group name",
tooltip = "Your Pseudo account name, or a Group name to trade many accounts at once",
group = "Account")
i_useGroup = input.bool(false, "This is a Group account",
tooltip = "Tick this if the name above is a Group account", group = "Account")
// ----- Instrument -----
i_symbol = input.string("BANKNIFTY", "Underlier symbol",
tooltip = "Underlier, e.g. NIFTY or BANKNIFTY", group = "Instrument")
i_exchange = input.string("NFO", "Options exchange code",
tooltip = "Options exchange code, e.g. NFO", group = "Instrument")
i_expiry = input.string("weekly", "Expiry",
tooltip = "weekly, next, monthly, or an exact date like 10-JUL-2026",
group = "Instrument")
// ----- Strategy -----
i_product = input.string("NORMAL", "Product type",
tooltip = "INTRADAY, DELIVERY or NORMAL", group = "Strategy")
i_lots = input.int(1, "Lots", minval = 1,
tooltip = "Number of lots for each leg", group = "Strategy")
i_shortPeriod = input.int(50, "Short MA Period", minval = 2, group = "Strategy")
i_longPeriod = input.int(200, "Long MA Period", minval = 3, group = "Strategy")
// ----- Order type -----
// Some brokers block MARKET orders in options. If so, tick "Use LIMIT orders"
// and set a limit price well above the option price so it fills like a market
// order (but keep it below the circuit limit).
i_useLimit = input.bool(false, "Use LIMIT orders", group = "Order")
i_price = input.float(0, "Limit price (only if using LIMIT)", minval = 0,
group = "Order")
// Build the straddle alert message. AutoTrader Web picks the at-the-money strike
// and the right expiry contract for you — no strike maths, no symbol building.
msg = atw.straddle(symbol = i_symbol, exchange = i_exchange, producttype = i_product,
account = i_useGroup ? "" : i_account,
group = i_useGroup ? i_account : "",
lots = i_lots, expiry = i_expiry,
ordertype = i_useLimit ? "LIMIT" : "MARKET",
price = i_useLimit ? i_price : 0)
// Moving averages, used only to spot a possible big move
shortAvg = ta.sma(close, i_shortPeriod)
longAvg = ta.sma(close, i_longPeriod)
plot(shortAvg, "Short MA", color = color.red, linewidth = 2)
plot(longAvg, "Long MA", color = color.blue, linewidth = 2)
longCondition = ta.crossover(shortAvg, longAvg)
shortCondition = ta.crossunder(shortAvg, longAvg)
// Enter a long straddle on either signal. The Up/Down label is only for the
// TradingView chart — both simply send the same buy-call + buy-put straddle to
// your account.
if longCondition
strategy.entry("Up", strategy.long, alert_message = msg)
if shortCondition
strategy.entry("Down", strategy.short, alert_message = msg)
Step 2: Add the strategy to the chart
- Make sure you selected the symbol of the underlying asset or its future (Ex. BANKNIFTY).
- Click the Add to Chart button (see image below).

No trades or arrows? Check the capital
If the Strategy Tester shows “This report requires trade data” and you see no arrows on the chart, the most common reason is the backtest capital. This strategy runs on a high-value underlier, and one position can cost more than the money set aside for the test, so the strategy places nothing.
Fix it in the strategy Settings → Properties tab: increase Initial capital so it can afford at least one position (a large value such as 10000000 works well). You can also lower the Order size, or set a Margin percentage to trade with leverage. As soon as the capital is enough, the arrows appear on the chart and the report fills in at the bottom.
Step 3: Set the strategy parameters
Parameters are grouped by their use-case.
Account
| Parameter | What it means |
|---|---|
| Account or Group name | The Pseudo account you want to trade into. To trade many accounts at once, enter a Group name here and tick the box below. |
| This is a Group account | Tick this if the name above is a Group account. |
Instrument
We use AutoTrader Web’s broker-independent instruments. You can use this instrument search tool.
| Parameter | What it means |
|---|---|
| Underlier symbol | The underlying symbol, for example NIFTY or BANKNIFTY. AutoTrader Web builds both option legs from this. |
| Options exchange code | The exchange code for the options, for example NFO. |
| Expiry | Which expiry to trade: weekly (this week), next (next weekly), monthly, or an exact date like 10-JUL-2026. |
Strategy
| Parameter | What it means |
|---|---|
| Product type | Use NORMAL (for carry-forward positions) or INTRADAY (for intraday positions). |
| Lots | Number of lots for each leg. One lot buys one lot of the call and one lot of the put. |
| Short MA Period | Short-term moving average value. |
| Long MA Period | Long-term moving average value. |
Order
| Parameter | What it means |
|---|---|
| Use LIMIT orders | Tick this if your broker does not allow MARKET orders in options. |
| Limit price | Only used with LIMIT orders. Set it well above the current option price, but below the circuit limit, so the buy fills just like a MARKET order. Example: if both the call and put you are buying trade around 700, set this to something higher, such as 1200. |

Step 4: Create the alert
- Press (Alt + A) to bring up the create alert window. You can also use the buttons shown in the screenshot below.
- Condition – Long Straddle
- Alert Actions
- Webhook – In AutoTrader Web, open Alert Auto. → Tokens, create a token and copy your private link. Turn on Webhook URL and paste it here:
- https://signals.stocksdeveloper.in/tradingview/YOUR-TOKEN
- You do not put your API key anywhere. Keep this link private, and you can revoke it any time.
- You can use any other alert actions as per your preference.
- Webhook – In AutoTrader Web, open Alert Auto. → Tokens, create a token and copy your private link. Turn on Webhook URL and paste it here:
- Alert Name – Any meaningful name (Ex. Long Straddle Alert).
- Message – We pass the alert content from the strategy, so use this placeholder (see screenshot below).
- {{strategy.order.alert_message}}


Optional: add a risk limit
You can attach your own risk limit to the straddle. For example, to add a maximum day-loss alert, add a risk argument to the atw.straddle(...) call:
msg = atw.straddle(symbol = i_symbol, exchange = i_exchange, producttype = i_product,
account = i_useGroup ? "" : i_account, group = i_useGroup ? i_account : "",
lots = i_lots, expiry = i_expiry,
ordertype = i_useLimit ? "LIMIT" : "MARKET", price = i_useLimit ? i_price : 0,
risk = atw.riskLimits(maxloss = 10000))
Risk limits are in early beta: right now they alert you by email and do not square off or block automatically yet. See the Alert Automation guide for the full list.
Disclaimer
This strategy is provided for demonstration purposes only. You can use it as learning or reference material. We do not promise any kind of financial returns based on this strategy.
Ideally, you should research and build your own strategies and backtest them before making them live.
Next steps
Thanks for the feedback. Still stuck? Contact support.
Last updated 8 July 2026