TradingView strategies, real orders at your broker.
TradingView alerts reach the New Order Copier on your own computer through the trade-commander relay. There are two ways. A position alert works with any strategy or indicator and needs no code. The free NOC Pine functions send your strategy's real orders - limit, stop, stop limit and market, with stop loss and take profit resting at the broker, changes and cancels included. The copier places them on every connected Interactive Brokers and MetaTrader account, with symbol mapping and size per account.
Position alert or real orders.
| POSITION ALERT | Paste one message into the alert of any strategy or indicator - no code. The alert states the position after the alert; the copier sends the difference as a market order. Stop loss and take profit act as the position changes they cause, not as orders at the broker. |
|---|---|
| NOC PINE FUNCTIONS | A block of Pine functions you copy into your own strategy. Each order of the strategy is sent as itself: market, limit, stop or stop limit, each with an optional stop loss and take profit that rest at the broker. A changed price, quantity, stop loss or take profit modifies the order; a cancel withdraws it; a close closes what it opened. |
| BOTH | Copied to every connected target account through its connector: symbol mapping table, multiplier, licence and logging work as for every other source. |
NOC_Demo.pine: the functions and a demonstration.
One Pine Script v6 file, free of charge, open source under the Mozilla Public License 2.0. It contains the NOC functions between the lines NOC functions BEGIN and NOC functions END, and the strategy NOC order types demo. On real-time bars the demo places, moves and cancels a limit, a stop and a stop limit order, then opens a market order, moves its stop loss and take profit and closes it. It demonstrates the chain; it is not a trading strategy.
The NOC functions.
Every function returns the alert text, or an empty text when there is nothing to send. Only real-time bars send; history and backtests send nothing.
| noc_new(token, qtyUnit) | Creates the book of what was sent; keep it in a var. qtyUnit = "contracts" (default): the quantity goes to the broker as it is - 1 = 1 contract, share or CFD unit at Interactive Brokers, 1 = 1 lot at MetaTrader. "lots": the mapping table's factor converts it first. |
|---|---|
| noc_order(book, oid, buy, otype, qty, price, stopPrice, sl, tp) | States an order: "MKT", "LMT", "STP" or "STPLMT". The first real-time call places it; a call with another price, quantity, stop loss or take profit modifies it; an unchanged call sends nothing, so it can be called on every bar. Side and type of an order id do not change: use a new id. |
| noc_cancel(book, oid) | Cancels an order: withdraws what still rests and closes what of it filled. |
| noc_closeOrder(book, oid) | Closes the position the order opened. |
| noc_closeAll(book) | Closes everything of this source on the chart's symbol. |
| noc_forget(book, oid) | Forgets an order that ended at the broker by itself (its stop loss or take profit closed it), so its id can be used again. |
//@version=6
strategy("My strategy", overlay = true)
// ... the NOC functions block (NOC functions BEGIN ... END) ...
// display.none: the token never shows in the chart legend or the alert name
string token = input.string("", "New Order Copier token (TV-...)", display = display.none)
var NocBook book = noc_new(token)
send(string m) =>
if m != ""
alert(m, alert.freq_all)
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30))
send(noc_order(book, "L1", true, "LMT", 1, price = close - 5, sl = close - 20, tp = close + 30))
Four steps.
| 1. COPIER | New Source → TradingView. Edit Source shows the webhook URL and the token, each with a Copy button. |
|---|---|
| 2. SCRIPT | Copy the NOC functions block into your strategy below its strategy(...) line and call noc_order where the strategy places its orders. Add the strategy to the chart and paste the token into its setting "New Order Copier token". |
| 3. ALERT | Condition: your strategy, "alert() function calls only". Notifications: tick only "Webhook URL" and paste the URL. Leave app and toast notifications off - they display the message, and the message contains the token. |
| 4. CONNECTOR | Switch on the connector from the TradingView source to each target account and give it a symbol mapping table that has the TradingView symbol as a row. |
Requirements and limits.
| REQUIREMENTS | A paid TradingView plan with webhooks and two-factor login enabled. The New Order Copier with a TradingView source, running while alerts arrive. |
|---|---|
| TOKEN | The token is the only key of the source: never post it, never show it in a screenshot or a shared script. One click on "New token" replaces it; every old alert stops at once. |
| LOST ALERTS | TradingView does not resend a failed webhook. An order sent while the copier is off is lost; its next change brings it back. |
| STALE ORDERS | A market order older than 45 seconds on arrival is not sent. |
| PRICES | Alerts are priced from TradingView's data feed. Your broker's price can differ; a limit order resting on TradingView can fill at once at the broker. |
| STOP LIMIT TO METATRADER | A buy stop limit's limit must be below its trigger, a sell's above - MetaTrader refuses it otherwise. Interactive Brokers takes either. |
| CHANGED SCRIPT | An alert keeps the script version it was created with: after a change, create the alert again. |
Risk disclaimer. Trading involves a risk of loss. The New Order Copier is software; it is not investment advice and makes no promise of results. Past results are no guarantee of future results.
Trademarks. TradingView is a trademark of TradingView, Inc. MetaTrader is a trademark of MetaQuotes Ltd. Interactive Brokers, IBKR, TWS and IB Gateway are trademarks of Interactive Brokers LLC. The New Order Copier works with these platforms; it is not affiliated with, endorsed or sponsored by any of these companies.
Checkout, payment and invoicing by Digistore24.