PINE LIBRARY
StocksDeveloperAlerts

Library "StocksDeveloperAlerts"
AutoTrader Web alert builder by Stocks Developer — turn TradingView alerts into real broker orders across many accounts and brokers. Ready-made functions for single orders, options the easy way, 8 option structures (straddle/strangle/spreads/iron condor/iron fly), custom multi-leg, account or group targeting, and your own risk limits. No alert-text typing. stocksdeveloper.in
order(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, optiontype, strike, expiry, spothint, usespot, onslicefailure, risk, extra)
Build an alert message for a single order (stock, futures or one option leg). This is the full builder; equity() and option() are shorter wrappers over it. Set exactly one of account/group and exactly one of lots/quantity. Add optiontype to make it an option order.
Parameters:
symbol (string): (series string) Broker-independent symbol, e.g. "NIFTY", "BANKNIFTY", "SBIN". For options, pass the underlier (e.g. "NIFTY"), not a full contract.
exchange (string): (series string) Exchange code, e.g. "NSE"/"BSE" for stocks, "NFO" for options and futures.
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
account (string): (series string) Place in this single account. Set this OR group.
group (string): (series string) Place in every live account in this group. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
optiontype (string): (series string) CE for a call, PE for a put. Adding this makes it an option order.
strike (string): (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500". Requires optiontype.
expiry (string): (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026". Requires optiontype.
spothint (string): (series string) Advanced: a spot price to help option-strike selection.
usespot (bool): (series bool) Advanced: use the spot hint for strike selection.
onslicefailure (string): (series string) Advanced: continue (default), alert or retry, if a large order that was auto-split has a slice fail.
risk (string): (series string) A risk block from risk() — for example risk=atw.risk(maxloss=5000).
extra (string): (series string) Advanced: any extra "key=value" lines to pass through unchanged (one per line).
Returns: (series string) The ready-to-send alert message.
equity(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, risk, extra)
Build an alert for a single stock or futures order (no option fields). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) Broker-independent symbol, e.g. "SBIN".
exchange (string): (series string) Exchange code, e.g. "NSE" or "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
option(symbol, exchange, producttype, tradetype, optiontype, strike, expiry, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, spothint, usespot, risk, extra)
Build an option order the easy way — give the underlier and pick the strike + expiry; no need to type the full option symbol. Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY", "BANKNIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
optiontype (string): (series string) CE for a call, PE for a put.
strike (string): (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500".
expiry (string): (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026".
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
spothint (string): (series string) Advanced: a spot price to help strike selection.
usespot (bool): (series bool) Advanced: use the spot hint for strike selection.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
straddle(symbol, exchange, producttype, account, group, lots, quantity, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Straddle — buy (or sell) a call and a put at the money. direction "BUY" = long straddle, "SELL" = short straddle.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) builds the structure as named; SELL flips every leg.
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue, if one leg cannot be placed.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
strangle(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Strangle — buy (or sell) an out-of-the-money call and put, each 'width' strikes out. direction "BUY" = long strangle, "SELL" = short strangle.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) How far out of the money the legs sit, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull call spread — buy a call at the money and sell a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear put spread — buy a put at the money and sell a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull put spread (credit) — sell a put at the money and buy a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear call spread (credit) — sell a call at the money and buy a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironCondor(symbol, exchange, producttype, account, group, lots, quantity, width, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron condor — sell a call and a put 'width' strikes out, and buy a call and a put 'width'+'wing' strikes out as protection. direction "BUY" builds this credit condor; "SELL" reverses it.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) How far out the sold legs sit, in strike steps (default 2).
wing (int): (series int) Extra distance out to the protective legs, in strike steps (defaults to width).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironFly(symbol, exchange, producttype, account, group, lots, quantity, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron fly — sell a call and a put at the money, and buy a call and a put 'wing' strikes out as protection. direction "BUY" builds this credit fly; "SELL" reverses it.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
wing (int): (series int) How far out the protective legs sit, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
leg(optiontype, strike, tradetype, multiplier)
Build one option leg string for use with multiLeg(), e.g. atw.leg("CE", "ATM+2", "SELL", 2) -> "CE ATM+2 SELL x2".
Parameters:
optiontype (string): (series string) CE for a call, PE for a put.
strike (string): (series string) ATM, ATM+2, OTM2, ITM1, or an exact strike like "24500".
tradetype (string): (series string) BUY or SELL for this leg.
multiplier (int): (series int) Size multiplier for this leg (default 1).
Returns: (series string) The leg descriptor.
multiLeg(symbol, exchange, producttype, legs, account, group, lots, quantity, expiry, ordertype, price, onlegfailure, risk, extra)
Build an alert for a fully custom multi-leg order from a list of legs (1 to 10) made with leg(). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
legs (array<string>): (array<string>) The legs, e.g. array.from(atw.leg("PE","ATM-2","SELL"), atw.leg("PE","ATM-6","BUY")).
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
riskLimits(maxloss, forceexit, entrywindow, blockExpiry)
Build a risk-limits block to attach to any order via risk=. Example: risk=atw.riskLimits(maxloss=5000). These are your own limits; see the Alert Automation guide for exactly how each one behaves.
Parameters:
maxloss (float): (series float) Maximum day loss for the account, in your account currency.
forceexit (string): (series string) A square-off time as "HH:mm", e.g. "15:15".
entrywindow (string): (series string) An allowed entry-time window "HH:mm-HH:mm", e.g. "09:30-14:30".
blockExpiry (bool): (series bool) Block new entries on the instrument's expiry day.
Returns: (series string) The risk lines, ready to pass as risk=.
AutoTrader Web alert builder by Stocks Developer — turn TradingView alerts into real broker orders across many accounts and brokers. Ready-made functions for single orders, options the easy way, 8 option structures (straddle/strangle/spreads/iron condor/iron fly), custom multi-leg, account or group targeting, and your own risk limits. No alert-text typing. stocksdeveloper.in
order(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, optiontype, strike, expiry, spothint, usespot, onslicefailure, risk, extra)
Build an alert message for a single order (stock, futures or one option leg). This is the full builder; equity() and option() are shorter wrappers over it. Set exactly one of account/group and exactly one of lots/quantity. Add optiontype to make it an option order.
Parameters:
symbol (string): (series string) Broker-independent symbol, e.g. "NIFTY", "BANKNIFTY", "SBIN". For options, pass the underlier (e.g. "NIFTY"), not a full contract.
exchange (string): (series string) Exchange code, e.g. "NSE"/"BSE" for stocks, "NFO" for options and futures.
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
account (string): (series string) Place in this single account. Set this OR group.
group (string): (series string) Place in every live account in this group. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
optiontype (string): (series string) CE for a call, PE for a put. Adding this makes it an option order.
strike (string): (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500". Requires optiontype.
expiry (string): (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026". Requires optiontype.
spothint (string): (series string) Advanced: a spot price to help option-strike selection.
usespot (bool): (series bool) Advanced: use the spot hint for strike selection.
onslicefailure (string): (series string) Advanced: continue (default), alert or retry, if a large order that was auto-split has a slice fail.
risk (string): (series string) A risk block from risk() — for example risk=atw.risk(maxloss=5000).
extra (string): (series string) Advanced: any extra "key=value" lines to pass through unchanged (one per line).
Returns: (series string) The ready-to-send alert message.
equity(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, risk, extra)
Build an alert for a single stock or futures order (no option fields). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) Broker-independent symbol, e.g. "SBIN".
exchange (string): (series string) Exchange code, e.g. "NSE" or "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
option(symbol, exchange, producttype, tradetype, optiontype, strike, expiry, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, spothint, usespot, risk, extra)
Build an option order the easy way — give the underlier and pick the strike + expiry; no need to type the full option symbol. Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY", "BANKNIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string): (series string) BUY or SELL.
optiontype (string): (series string) CE for a call, PE for a put.
strike (string): (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500".
expiry (string): (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026".
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
ordertype (string): (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float): (series float) Limit price (required for LIMIT).
triggerprice (float): (series float) Trigger price (for stop-loss orders).
validity (string): (series string) DAY (default) or IOC.
amo (bool): (series bool) true for an after-market order.
spothint (string): (series string) Advanced: a spot price to help strike selection.
usespot (bool): (series bool) Advanced: use the spot hint for strike selection.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
straddle(symbol, exchange, producttype, account, group, lots, quantity, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Straddle — buy (or sell) a call and a put at the money. direction "BUY" = long straddle, "SELL" = short straddle.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) builds the structure as named; SELL flips every leg.
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue, if one leg cannot be placed.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
strangle(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Strangle — buy (or sell) an out-of-the-money call and put, each 'width' strikes out. direction "BUY" = long strangle, "SELL" = short strangle.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) How far out of the money the legs sit, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull call spread — buy a call at the money and sell a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear put spread — buy a put at the money and sell a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull put spread (credit) — sell a put at the money and buy a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear call spread (credit) — sell a call at the money and buy a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironCondor(symbol, exchange, producttype, account, group, lots, quantity, width, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron condor — sell a call and a put 'width' strikes out, and buy a call and a put 'width'+'wing' strikes out as protection. direction "BUY" builds this credit condor; "SELL" reverses it.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
width (int): (series int) How far out the sold legs sit, in strike steps (default 2).
wing (int): (series int) Extra distance out to the protective legs, in strike steps (defaults to width).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironFly(symbol, exchange, producttype, account, group, lots, quantity, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron fly — sell a call and a put at the money, and buy a call and a put 'wing' strikes out as protection. direction "BUY" builds this credit fly; "SELL" reverses it.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
wing (int): (series int) How far out the protective legs sit, in strike steps (default 2).
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
direction (string): (series string) BUY (default) or SELL (flips every leg).
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
leg(optiontype, strike, tradetype, multiplier)
Build one option leg string for use with multiLeg(), e.g. atw.leg("CE", "ATM+2", "SELL", 2) -> "CE ATM+2 SELL x2".
Parameters:
optiontype (string): (series string) CE for a call, PE for a put.
strike (string): (series string) ATM, ATM+2, OTM2, ITM1, or an exact strike like "24500".
tradetype (string): (series string) BUY or SELL for this leg.
multiplier (int): (series int) Size multiplier for this leg (default 1).
Returns: (series string) The leg descriptor.
multiLeg(symbol, exchange, producttype, legs, account, group, lots, quantity, expiry, ordertype, price, onlegfailure, risk, extra)
Build an alert for a fully custom multi-leg order from a list of legs (1 to 10) made with leg(). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string): (series string) The underlier, e.g. "NIFTY".
exchange (string): (series string) Options exchange code, e.g. "NFO".
producttype (string): (series string) INTRADAY, DELIVERY, NORMAL or MTF.
legs (array<string>): (array<string>) The legs, e.g. array.from(atw.leg("PE","ATM-2","SELL"), atw.leg("PE","ATM-6","BUY")).
account (string): (series string) Single account. Set this OR group.
group (string): (series string) Group of accounts. Set this OR account.
lots (int): (series int) Number of lots. Set this OR quantity.
quantity (int): (series int) Exact quantity. Set this OR lots.
expiry (string): (series string) weekly (default), next, monthly, or an exact date.
ordertype (string): (series string) MARKET (default) or LIMIT.
price (float): (series float) Limit price (required for LIMIT).
onlegfailure (string): (series string) alert (default), cancel or continue.
risk (string): (series string) A risk block from risk().
extra (string): (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
riskLimits(maxloss, forceexit, entrywindow, blockExpiry)
Build a risk-limits block to attach to any order via risk=. Example: risk=atw.riskLimits(maxloss=5000). These are your own limits; see the Alert Automation guide for exactly how each one behaves.
Parameters:
maxloss (float): (series float) Maximum day loss for the account, in your account currency.
forceexit (string): (series string) A square-off time as "HH:mm", e.g. "15:15".
entrywindow (string): (series string) An allowed entry-time window "HH:mm-HH:mm", e.g. "09:30-14:30".
blockExpiry (bool): (series bool) Block new entries on the instrument's expiry day.
Returns: (series string) The risk lines, ready to pass as risk=.
Pineライブラリ
TradingViewの精神に則り、作者はこのPineコードをオープンソースライブラリとして公開してくれました。コミュニティの他のPineプログラマーが再利用できるようにという配慮です。作者に拍手を!このライブラリは個人利用や他のオープンソースの公開コンテンツで使用できますが、公開物でのコードの再利用はハウスルールに準じる必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
Pineライブラリ
TradingViewの精神に則り、作者はこのPineコードをオープンソースライブラリとして公開してくれました。コミュニティの他のPineプログラマーが再利用できるようにという配慮です。作者に拍手を!このライブラリは個人利用や他のオープンソースの公開コンテンツで使用できますが、公開物でのコードの再利用はハウスルールに準じる必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。