PINE LIBRARY
Updated VoltRouter Webhook Builder

Build TradingView alert webhook payloads for VoltRouter — a signal routing service that executes your TradingView strategy alerts directly at your broker. $0.07/signal, pay-as-you-go, no subscription required.
Supports: market, limit, stop, bracket (TP+SL), trailing stop, FLAT, and cancel-all.
How to use:
1. Sign up at voltrouter.com and connect your broker
2. Import this library in your strategy
3. Paste the output into a TradingView alert → Webhook URL field
Setup: voltrouter.com/docs
import VoltRouterWebhook as vr
// In your strategy alert message field:
vr.market("MNQM26", "buy", 1, "ibkr", "my_strategy")
vr.bracket("MNQM26", "sell", 1, close + 10, close - 5)
vr.flat("MNQM26")
Supports: market, limit, stop, bracket (TP+SL), trailing stop, FLAT, and cancel-all.
How to use:
1. Sign up at voltrouter.com and connect your broker
2. Import this library in your strategy
3. Paste the output into a TradingView alert → Webhook URL field
Setup: voltrouter.com/docs
import VoltRouterWebhook as vr
// In your strategy alert message field:
vr.market("MNQM26", "buy", 1, "ibkr", "my_strategy")
vr.bracket("MNQM26", "sell", 1, close + 10, close - 5)
vr.flat("MNQM26")
Release Notes
v2Updated:
market(symbol, action, quantity, apiKey, broker, strategy)
market
description Market order — executes immediately at best available price.
Parameters:
symbol (string): Ticker symbol e.g. "MNQM26" or "AAPL".
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate". Defaults to "ibkr".
strategy (string): Optional strategy tag for grouping in the signal log.
Returns: JSON string ready to paste into a TradingView alert webhook body.
limit(symbol, action, quantity, limitPrice, apiKey, broker, strategy)
limit
description Limit order — rests at the specified price or better.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
limitPrice (float): Limit price.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
stop(symbol, action, quantity, stopPrice, apiKey, broker, strategy)
stop
description Stop order — triggers a market order when price crosses the stop level.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
stopPrice (float): Price that triggers the order.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
bracket(symbol, action, quantity, limitPrice, stopPrice, apiKey, broker, strategy)
bracket
description Bracket order — entry + take-profit + stop-loss in a single signal. Send limit_price and stop_price together.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
limitPrice (float): Take-profit price.
stopPrice (float): Stop-loss price.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
trailingStop(symbol, action, quantity, trailPercent, apiKey, broker, strategy)
trailingStop
description Trailing stop — stop trails the market by a percentage.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
trailPercent (float): Trail amount as a percentage e.g. 1.5 = 1.5%.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
flat(symbol, apiKey, broker, strategy)
flat
description FLAT — closes the entire position for the symbol immediately.
Parameters:
symbol (string): Ticker symbol.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
cancelAll(symbol, apiKey, broker)
cancelAll
description Cancels all open orders for the symbol.
Parameters:
symbol (string): Ticker symbol.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
Returns: JSON string.
Release Notes
Builds VoltRouter webhook payloads for TradingView alerts. Route signals to IBKR, Alpaca, or Tradovate via voltrouter.com — docs at voltrouter.com/docs⚠️ v2 contains breaking changes — see changelog in source.
Release Notes
v3 Updated description and pricing copy. No code changes.Never run IB Gateway again.
VoltRouter hosts IB Gateway for you — connect your TradingView strategy to IBKR, Alpaca, or Tradovate without touching a VPS, managing sessions, or debugging disconnects.
$0.07/signal, pay-as-you-go. IBKR users: $5/mo covers hosted IB Gateway — no VPS, no session management, no restarts.
How to use:
1. Sign up at voltrouter.com and connect your broker
2. Import this library in your strategy
3. Paste the output into a TradingView alert → Webhook URL field
Supports: market, limit, stop, bracket (TP+SL), trailing stop, FLAT, and cancel-all.
Setup guide: voltrouter.com/docs
Release Notes
v2
Updated:
market(symbol, action, quantity, apiKey, broker, strategy)
market
description Market order — executes immediately at best available price.
Parameters:
symbol (string): Ticker symbol e.g. "MNQM26" or "AAPL".
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate". Defaults to "ibkr".
strategy (string): Optional strategy tag for grouping in the signal log.
Returns: JSON string ready to paste into a TradingView alert webhook body.
limit(symbol, action, quantity, limitPrice, apiKey, broker, strategy)
limit
description Limit order — rests at the specified price or better.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
limitPrice (float): Limit price.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
stop(symbol, action, quantity, stopPrice, apiKey, broker, strategy)
stop
description Stop order — triggers a market order when price crosses the stop level.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
stopPrice (float): Price that triggers the order.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
bracket(symbol, action, quantity, limitPrice, stopPrice, apiKey, broker, strategy)
bracket
description Bracket order — entry + take-profit + stop-loss in a single signal. Send limit_price and stop_price together.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
limitPrice (float): Take-profit price.
stopPrice (float): Stop-loss price.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
trailingStop(symbol, action, quantity, trailPercent, apiKey, broker, strategy)
trailingStop
description Trailing stop — stop trails the market by a percentage.
Parameters:
symbol (string): Ticker symbol.
action (string): "buy" or "sell"
quantity (int): Number of contracts or shares.
trailPercent (float): Trail amount as a percentage e.g. 1.5 = 1.5%.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
flat(symbol, apiKey, broker, strategy)
flat
description FLAT — closes the entire position for the symbol immediately.
Parameters:
symbol (string): Ticker symbol.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
strategy (string): Optional strategy tag.
Returns: JSON string.
cancelAll(symbol, apiKey, broker)
cancelAll
description Cancels all open orders for the symbol.
Parameters:
symbol (string): Ticker symbol.
apiKey (string): Your VoltRouter API key.
broker (string): Target broker. Defaults to "ibkr".
Returns: JSON string.
14 hours ago
Release Notes
Builds VoltRouter webhook payloads for TradingView alerts. Route signals to IBKR, Alpaca, or Tradovate via voltrouter.com — docs at voltrouter.com/docs
⚠️ v2 contains breaking changes — see changelog in source.
Release Notes
v4Updated:
market(symbol, action, quantity, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
market
description Market order — executes immediately at best available price.
Parameters:
symbol (string): Ticker symbol e.g. "MNQ", "ES", "AAPL". Futures symbol for IBKR; equity ticker for Alpaca.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry: YYYYMM (e.g. "202606") or CME code (e.g. "MNQM26"). Omit for front month. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours. IBKR and Alpaca. Defaults to false.
strategyId (string): Tag for order modification and grouping. Appears in signal log.
clientOrderId (string): Idempotency key — duplicate signals with the same key are discarded and not charged.
account (string): Broker account label. Omit to use the primary account.
Returns: JSON string ready to paste into a TradingView alert webhook body.
limit(symbol, action, quantity, takeProfitPrice, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
limit
description Limit order — rests at the specified price or better.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
takeProfitPrice (float): Limit price (take profit).
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
stop(symbol, action, quantity, stopLossPrice, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
stop
description Stop order — triggers a market order when price crosses the stop level.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
stopLossPrice (float): Price that triggers the stop-market order.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
stopLimit(symbol, action, quantity, takeProfitPrice, stopLossPrice, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
stopLimit
description Stop-limit order — triggers a limit order when price crosses the stop level.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
takeProfitPrice (float): Limit price once the stop triggers.
stopLossPrice (float): Stop trigger price.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
bracket(symbol, action, quantity, takeProfitPrice, stopLossPrice, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
bracket
description Bracket order — entry with take-profit limit and stop-loss stop in a single signal.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
takeProfitPrice (float): Take-profit price. Fills as a limit order.
stopLossPrice (float): Stop-loss price. Triggers as a stop-market. Mutually exclusive with trailingStopPercent.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
trailingStop(symbol, action, quantity, trailPercent, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
trailingStop
description Trailing stop — stop trails the market by a percentage. Mutually exclusive with stop_loss_price.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
trailPercent (float): Trail amount as a percentage (0.1–100). e.g. 1.5 = 1.5%.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
flat(symbol, broker, apiKey, strategyId, clientOrderId, account)
flat
description FLAT — closes the entire position for the symbol immediately.
Parameters:
symbol (string): Ticker symbol.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
Removed:
cancel(symbol, broker, apiKey, ibkrOrderId, strategyId, account)
cancel
description Cancels a specific open order by ibkr_order_id or strategy_id.
cancelAll(symbol, broker, apiKey, strategyId, account)
cancelAll
description Cancels all open orders for the symbol.
Release Notes
v6Added:
bracketWithTrail(symbol, action, quantity, takeProfitPrice, trailPercent, broker, apiKey, expiry, extendedHours, strategyId, clientOrderId, account)
bracketWithTrail
description Bracket order with a trailing stop instead of a fixed stop-loss.
Parameters:
symbol (string): Ticker symbol.
action (string): "BUY" or "SELL"
quantity (int): Number of contracts or shares.
takeProfitPrice (float): Take-profit limit price.
trailPercent (float): Trailing stop distance as a percentage e.g. 1.5 = 1.5%.
broker (string): Target broker: "ibkr" | "alpaca" | "tradovate".
apiKey (string): Your VoltRouter API key.
expiry (string): Contract expiry. IBKR futures only.
extendedHours (bool): Allow fill outside regular trading hours.
strategyId (string): Optional strategy tag.
clientOrderId (string): Idempotency key.
account (string): Broker account label.
Returns: JSON string.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.