How to Automate Pine Script for Live Prop Firm Trading

Watching a chart and clicking buy/sell in real time works fine on paper. On a live evaluation it introduces latency, hesitation, and the psychological weight of a red session. Automation removes all of it — here's the full setup.

Manually executing a Pine Script strategy — waiting for the signal, clicking the order in — is a different failure mode than the strategy itself failing. Human reaction time, second-guessing a valid signal, and the temptation to override a system after a loss are the actual causes behind a lot of blown evaluations, not the underlying rules. Automation takes the trader out of the execution loop entirely: the strategy either fires or it doesn't, and a kill switch either halts trading or it doesn't.

This guide walks through the full TradingView + TradersPost + broker stack, from creating a TradersPost account to the exact alert message format to the Bar Magnifier setting that trips up a lot of first-time automators.

Why automation matters for prop firms

A prop firm evaluation tests one thing: whether a trader can execute a rules-based approach consistently over a defined stretch. The rules themselves are usually clear — profit target, drawdown limit, maybe a daily loss cap, maybe a session restriction. The failure rate stays high anyway, because human traders break their own systems under pressure far more often than the rules themselves are actually difficult.

Automation enforces the plan mechanically, in three specific ways relevant to a prop firm account:

  • No emotional entries. The strategy fires at bar close when its conditions are met — not when a trader feels confident enough after watching the chart for twenty minutes. Discretionary overrides are one of the most common sources of out-of-system trades that blow an evaluation.
  • Consistent rule execution. Session filters, news blackouts, and kill switches run exactly as coded, every time. A tired human trader might take "just one more" at 3:45pm when the session filter should have already stopped entries — the script doesn't.
  • Daily loss limits actually hit. Stopping trading after a loss is the hardest discipline for most traders to hold. For a script it's one conditional check. See our guide on passing the Topstep Combine for how a daily loss limit interacts with an automated kill switch in practice.
On firms with a published daily loss limit — Topstep at $1,000 on the 50k, for example — a properly coded kill switch isn't optional. It's the difference between an ordinary losing day and a blown evaluation.

The TradingView → TradersPost → broker stack

The standard automation architecture for prop firm futures trading has three layers, each doing exactly one job:

LayerToolRole
Signal generationTradingViewPine Script runs here and produces entries/exits
Order routingTradersPostWebhook receiver — converts alerts into broker API calls
ExecutionTradovate or RithmicPlaces the live fill on your prop firm account

TradingView generates the signal, TradersPost turns it into a broker order, and the broker fills it on your account. The trader's job shifts from executing to monitoring — watching the P&L and stepping in only if something looks wrong.

Step 1: Set up a TradersPost account

TradersPost is the webhook middleware between TradingView and a broker — TradingView alone can't place trades, so without a bridge like this there's no way to connect a chart signal to a live order.

  1. Create a TradersPost account and connect a broker — add your Tradovate or Rithmic account under Brokers, using the API credentials generated from within that platform.
  2. Create a Strategy inside TradersPost, named to match your Pine Script strategy. Select the connected broker and the instrument you'll trade (e.g. MES1!, MNQ1!, NQ1!).
  3. Copy the Webhook URL from the strategy page. Keep it private — anyone holding it can send orders to the linked account.
TradersPost also supports a paper trading mode. Run the full setup there for a few sessions before connecting a live evaluation account, to confirm alerts are flowing and orders are generating correctly.

Step 2: Connect the broker to a prop firm account

Most futures prop firms run on Tradovate or Rithmic. Apex, Take Profit Trader, and MyFundedFutures all support Tradovate; Topstep supports both. The firm provides connection instructions during onboarding.

  1. Generate an API key or OAuth credential from the broker platform's API settings.
  2. Enter those credentials in TradersPost, under the connected broker, to link the account.
  3. Select the specific account ID that corresponds to the evaluation — most broker dashboards show several accounts, so confirm the right one is selected.
  4. Send a test order through TradersPost's built-in test tool to confirm connectivity without risking a real fill.

Step 3: Configure the Pine Script strategy for automation

Not every Pine Script strategy is automation-ready. Before creating any alert, confirm the script meets these requirements:

  • Bar-close execution. Entries should fire on a confirmed bar close (Pine Script's barstate.isconfirmed guard), not on intrabar ticks — this keeps the backtest and the live result consistent.
  • Native alert message format. The strategy needs to generate signals through strategy.entry() and strategy.exit() so TradingView's built-in order alert variable works. A custom message hard-coded into an alert() call won't carry the structured order data TradersPost needs.
  • Defined stop and target. Explicit values passed to strategy.exit() keep backtest and live exits identical.
  • A session filter. A time-based guard that blocks entries outside the intended trading window — a simple RTH filter checks the current time against a defined session string.

Step 4: Configure the TradingView alert — the exact message format

This is where most first-time automators make the mistake that causes automation to fail silently. The alert message field must be set to exactly:

{{strategy.order.alert_message}}

That isn't a custom message — it's a TradingView template variable that expands to a JSON object carrying the order action, ticker, and quantity your strategy generated. TradersPost reads that JSON to know what order to place.

  1. With the strategy applied to a chart, click the Alert icon.
  2. Under Condition, choose the strategy name, then select Order fills — this fires on every order event (entry, exit, stop).
  3. In the Message field, clear any default text and enter exactly {{strategy.order.alert_message}}.
  4. Under Notifications, enable Webhook URL and paste the TradersPost webhook URL from Step 1.
  5. Name the alert descriptively (e.g. "MES Starter — Live Eval") and set an appropriate expiration date.
  6. Click Create.
Typing a custom message instead of {{strategy.order.alert_message}} means TradersPost receives a plain text string instead of structured JSON — it will reject the alert. TradingView's alert log will still show the alert firing, but nothing happens in the broker account.

Step 5: Enable Bar Magnifier for backtest/live parity

Bar Magnifier changes how TradingView's backtest engine simulates fills within a single candle. By default, TradingView assumes a stop or target fills at its exact price when the bar closes past it. With Bar Magnifier on, the engine uses higher-resolution intrabar data to model stop hits more realistically — catching a wick that would genuinely have triggered a stop even if the bar closed on the other side of it.

strategy("My Strategy", overlay = true, use_bar_magnifier = true)

Or via the UI: Settings → Properties → Fill orders → Using bar magnifier. It doesn't change how live alerts fire — those still trigger on bar close either way — but it does make the backtest's win rate, average trade, and drawdown numbers a more honest preview of live performance. Without it, a backtest can look cleaner than live trading will actually be, especially on wick-heavy instruments like NQ and MNQ. See our guide on the Apex consistency rule for how an unexpected stop-out can ripple into consistency metrics on a funded account.

Common mistakes that break Pine Script automation

1. Wrong alert message format

Symptom: alerts fire in TradingView's history but nothing shows up in TradersPost or the broker. Check TradersPost's webhook log — a plain text string instead of JSON means the message field is wrong. Delete the alert and recreate it with only the order alert template variable in the message box.

2. Missing webhook URL

Symptom: alerts fire but nothing reaches TradersPost. Confirm the alert's Webhook URL field is populated and hasn't been regenerated or expired on the TradersPost side — a blank field means the alert is only firing a notification, no API call.

3. Never enabling Bar Magnifier

Symptom: clean backtest, noticeably worse live fills. Enable it, rerun the backtest, and compare the updated numbers to live performance — the gap should close substantially.

4. Wrong account selected in TradersPost

Symptom: orders route to the wrong account — sometimes a personal one, sometimes the wrong evaluation. Verify the linked account ID under the broker connection matches the intended evaluation account number.

5. Alert set on an indicator instead of the strategy

Symptom: the alert fires but carries no order data, because the condition was set against a plotted indicator value rather than the strategy's order fills. Confirm the alert condition targets the strategy name with Order fills selected.

6. Missing or misconfigured session filter

Symptom: orders firing overnight when the market is thin, producing outsized slippage. A hard session filter blocking entries outside the intended hours is especially important on a trailing-drawdown account, where an overnight-gap-induced stop can eat into the floor in a single candle.

Building a daily kill switch that actually holds

A daily loss kill switch is simple in concept — track realized P&L from session open, compare it to a threshold, halt new entries once it's crossed, reset at the next session — but easy to get subtly wrong in practice (forgetting to exclude an already-open position's unrealized P&L from the reset, for example). The working shape:

  • Daily P&L tracking from the session's opening equity, tracked separately from any open position's unrealized value.
  • A configurable threshold — typically 75–85% of the firm's published limit (or of a self-imposed cap, on firms with none), leaving room for slippage on the exit that actually closes the position.
  • A hard halt on new entries once the threshold is crossed. Existing positions still manage to their own stop/target — the kill switch blocks new entries, not open exits.
  • A session reset at the start of the next trading day, resuming entries if every other condition is satisfied.

This is the difference between a prop-firm-ready Pine Script and a generic public TradingView script — most public scripts have no kill switch at all. Running one on an account with a real daily loss limit is a question of when, not whether, it eventually chains enough losers in a session to breach it. For more on how limits differ by firm, see our guides on passing the Apex evaluation and passing the Topstep Combine — each firm's rule set has different implications for how a kill switch should be configured.

Monitoring an automated strategy in live trading

Once automation is running, the job shifts from executing trades to watching the system. What to check regularly:

  • TradersPost's webhook log — check after every session for failed deliveries or malformed payloads. One missed alert can mean one missed trade, or worse, a position left open.
  • The broker's position panel — confirm it matches what TradingView's strategy believes is the current position. A mismatch usually means an exit alert didn't fire or wasn't received.
  • End-of-day reconciliation — compare the strategy's backtest-style P&L to the broker's actual fills. A few ticks of slippage is normal on MES/MNQ; consistently large slippage points to a liquidity or timing issue.
  • Alert expiration — TradingView alerts expire on a set date. An expired alert fires nothing, and a missed session might not be noticed until after the fact.

FAQ — Pine Script automation

What is the best way to automate a Pine Script strategy for prop firm trading?
The TradingView + TradersPost + broker stack is the most common, reliable approach. TradingView generates order alerts from a Pine Script strategy, TradersPost converts each alert into a broker order over a webhook, and the broker executes it on your prop firm account. This works for MES, MNQ, ES, NQ, and other CME futures.
What should the TradingView alert message be set to for automation?
Set the message field to exactly the strategy order alert template variable — this tells TradingView to pass the built-in order data (action, instrument, quantity) with each alert. Typing a custom message instead means TradersPost receives plain text rather than the structured order data it expects, and no order gets placed.
Do I need Bar Magnifier enabled for live trading?
Bar Magnifier changes how TradingView's backtester simulates intrabar stop hits — it doesn't change how live orders are sent, since alerts still fire at bar close either way. Enabling it does keep backtest results closer to what live trading actually produces, which is worth having before trusting a backtest's numbers.

Get a Pine Script tuned to your prop firm.

Invite-only on TradingView within 24 hours. From $19/mo, cancel anytime.