Pine Script Webhook JSON for TradersPost
Fires the exact JSON payload TradersPost expects from a TradingView alert — buy, sell, and exit actions, all built at runtime with alert().
//@version=6
strategy("Target Filled - TradersPost Webhook Example", overlay=true, calc_on_every_tick=false)
// --- Inputs ---------------------------------------------------
orderQty = input.int(1, "Contracts", minval=1)
// --- Sample signal — replace with your own entry logic ---------
fastMA = ta.ema(close, 9)
slowMA = ta.ema(close, 21)
goLong = ta.crossover(fastMA, slowMA)
goShort = ta.crossunder(fastMA, slowMA)
// --- TradersPost JSON payloads (assembled at runtime) -----------
// Dialog {{placeholders}} are not substituted inside alert() — build
// the string yourself with str.tostring.
buyPayload = '{"ticker": "' + syminfo.ticker + '", "action": "buy", "quantity": ' + str.tostring(orderQty) + '}'
sellPayload = '{"ticker": "' + syminfo.ticker + '", "action": "sell", "quantity": ' + str.tostring(orderQty) + '}'
flatPayload = '{"ticker": "' + syminfo.ticker + '", "action": "exit"}'
if goLong
strategy.entry("Long", strategy.long, qty=orderQty)
alert(buyPayload, alert.freq_once_per_bar_close)
if goShort
strategy.entry("Short", strategy.short, qty=orderQty)
alert(sellPayload, alert.freq_once_per_bar_close)
// Call from your own flatten logic when closing out:
// alert(flatPayload, alert.freq_once_per_bar_close) Settings
| Input | Default | Purpose |
|---|---|---|
| orderQty | 1 | Contract quantity sent in the payload and used for the entry. |
How to use
- Paste into the Pine Editor, add to chart, and swap the EMA-crossover placeholder for your own entry conditions.
- Create one alert on the strategy: condition "Order fills and alert() function calls," and paste your TradersPost webhook URL into the Notifications tab.
- Leave the alert dialog's message box untouched — the JSON comes from
alert()at runtime, not from the dialog template. - Test against a TradersPost paper account before pointing the alert at anything funded.
Which firms allow this
Automation policy varies by firm. Current stance for two firms commonly paired with TradersPost:
| Firm | Automation Policy |
|---|---|
| Apex Trader Funding | Allowed during the evaluation. Not allowed for commercial/resold automation on live Performance Accounts — a script may still drive manual-confirm execution. |
| Topstep | Full automation permitted on the Combine (evaluation). Funded-account automation policy has changed multiple times; semi-automation (script alerts, manual confirmation) is the stated safer default rather than an outright ban. |
On NinjaTrader 8 or Tradovate? Automate with CrossTrade
If your account runs on NinjaTrader 8 or Tradovate, CrossTrade is the automation platform we recommend. It connects TradingView alerts to NinjaTrader 8 through a desktop add-on, and to Tradovate in the cloud with nothing to install. Its Account Manager can also hold a max daily loss, max daily profit, and trailing drawdown on each account, flattening and locking the account when one is hit. On NinjaTrader, those limits run while NinjaTrader and the add-on are running.
A CrossTrade alert message is a list of key=value lines rather than JSON, and it
doesn't need alert() at all. Create one alert on the strategy, set the condition
to "Order fills only," and paste this into the alert's message box:
key=your-secret-key;
command=place;
account=sim101;
instrument=ES1!;
action={{strategy.order.action}};
qty={{strategy.order.contracts}};
order_type=market;
tif=day; - TradingView fills in
{{strategy.order.action}}(buy or sell) and{{strategy.order.contracts}}each time the strategy's order fills, so the strategy's own entries and exits drive the orders. - Swap
your-secret-key,sim101, andES1!for your own CrossTrade key, account, and instrument. The CrossTrade docs cover every field. - Paste your own CrossTrade webhook URL into the alert's Notifications tab. Webhook alerts need a paid TradingView plan.
- "Order fills only" keeps the TradersPost
alert()payloads from the snippet above out of this alert, so CrossTrade only receives its own message. - Check your firm's current automation rules before connecting a prop firm account.
CrossTrade offers a 7-day free trial, no credit card required. Target Filled is built by the team behind CrossTrade, the automation platform we recommend.
Frequently Asked Questions
What JSON does TradersPost expect from TradingView?
{"ticker": "MNQ1!", "action": "buy", "quantity": 1}. Supported actions include buy, sell, and exit. TradersPost reads this straight out of the alert message body and routes the order to whichever broker you've connected.How do I send a webhook alert from Pine Script?
alert() with the JSON string from inside your order logic, using alert.freq_once_per_bar_close so it only fires once per signal. Then create a single alert on the strategy in TradingView, choose "Order fills and alert() function calls," and paste your TradersPost webhook URL into the notifications tab.Should I use alert() or alertcondition()?
alert(). It builds the message at runtime with str.tostring, fires directly from order logic, and needs only one alert set up in TradingView. alertcondition() only works in indicators, can't see strategy fills, and needs a separate alert per condition.