Skip to main content

Automating TradingView Indicators (Tradovate)

Indicators are often the easiest thing to automate. A strategy tracks its own position state and you have to keep TradingView and your broker in sync. An indicator just says "buy signal here" or "sell signal here" — you decide what each of those means, and each alert carries a complete, hardcoded command. No offsetting requirements, no sync ambiguity.

This guide assumes you've already sent a working test order. If you haven't, start with Your First Automated Trade.

The Setup: Two Alerts, Two Directions

Most indicator automations are two TradingView alerts on the same indicator: one for the buy condition, one for the sell condition. Each has its own hardcoded payload.

The BUY alert:

key=your-secret-key;
command=PLACE;
account=DemoAccount;
instrument=MES1!;
action=BUY;
qty=1;
order_type=MARKET;
tif=DAY;
flatten_first=true;
destination=tradovate;

The SELL alert:

key=your-secret-key;
command=PLACE;
account=DemoAccount;
instrument=MES1!;
action=SELL;
qty=1;
order_type=MARKET;
tif=DAY;
flatten_first=true;
destination=tradovate;

With flatten_first=true; on both, each signal closes whatever position exists on that contract and enters fresh in the signal's direction. That one field turns two dumb alerts into a complete always-in-the-market reversal system: buy signal makes you long one contract, sell signal makes you short one contract, no stacking.

If you only want to trade one direction, use the buy alert for entries and make the sell alert an exit instead:

key=your-secret-key;
command=CLOSEPOSITION;
account=DemoAccount;
instrument=MES1!;
destination=tradovate;

On Tradovate, CLOSEPOSITION uses the broker's liquidate endpoint for a full close, which also clears the contract's working orders.

Setting Up the Alert Conditions

Create each alert from the indicator's own condition dropdown in TradingView (for a built-in like a moving average cross, pick the crossing direction; for a third-party indicator, pick its buy/sell plots). Two rules:

  1. Delete everything in the message box and paste only the CrossTrade command. Leftover indicator text breaks the payload.
  2. Set the webhook URL on the Notifications tab of both alerts.

Adding Exit Management

A market entry with no exit plan isn't automation, it's exposure. You have three options on Tradovate, all server-side:

Option A: A simple bracket. Add take_profit and stop_loss to the entry. CrossTrade sends the entry plus both exits as one native OSO order: the target and stop live on Tradovate's servers, linked as an OCO, and survive your computer being off.

key=your-secret-key;
command=PLACE;
account=DemoAccount;
instrument=MES1!;
action=BUY;
qty=1;
order_type=MARKET;
take_profit=40;
stop_loss=20;
destination=tradovate;

Bare numbers are tick offsets from entry; absolute prices and pt/percentage/dollar forms work too. Relative offsets are resolved to real prices by CrossTrade's quote service at send time, and the alert fails closed if no fresh quote is available.

Option B: A scale-out ATM. For multi-target exits (scale out half at the first target, trail the runner, auto-breakeven), use the inline atm_* fields or a named CrossTrade ATM Template. This builds a native Tradovate multibracket order strategy. See Order Types and Exits on Tradovate for the full treatment.

Option C: Indicator-driven exits. Skip brackets entirely and let the opposite signal close the position (flatten_first=true reversal style, or an explicit CLOSEPOSITION alert). Simple, but you're unprotected between signals — most people combine this with a wide catastrophic stop_loss from Option A.

Adding Position Protection

Indicator signals fire whenever their condition is true, including at moments you'd rather they didn't. Three fields keep alerts from doing something you don't want:

Prevent duplicate entries. require_market_position=flat; makes the entry fire only when the account is flat on that instrument. On Tradovate this gate is evaluated against the live broker position (derived from the real-time fill stream, so back-to-back alerts see the truth). Combinations like long,flat work too.

Limit simultaneous positions. max_positions=2; blocks an opening order that would add a new instrument once the account already holds two open positions. Scaling an existing instrument doesn't consume another slot.

Restrict trading hours. start_time and end_time bound when alerts are allowed to execute, and closing_only_after lets exits through while blocking new entries late in your session. These trade-window controls apply on both destinations.

key=your-secret-key;
command=PLACE;
account=DemoAccount;
instrument=MES1!;
action=BUY;
qty=1;
order_type=MARKET;
require_market_position=flat;
start_time=09:30;
end_time=15:45;
take_profit=40;
stop_loss=20;
destination=tradovate;

Sending to Multiple Accounts

Give account a comma-separated list and the order places on each account independently, each with its own Alert History row:

account=APEX1234,APEX1235;

Relative bracket prices are resolved once before fan-out, so every account uses the same quote basis. Add cycle_accounts=true; to rotate signals across the list (one account per signal) instead of hitting all of them — accounts locked by an Account Manager monitor are skipped automatically. For follower sizing, inversion, and symbol replacement, use the Tradovate Copier instead; the comparison is covered in Managing Multiple Tradovate Accounts.

Common Indicator Automation Mistakes

Leaving TradingView's default text in the message box. The payload must be the only content. This is the number one failure.

Forgetting destination=tradovate; on one of the two alerts. The buy goes to Tradovate, the sell silently routes to NT8 (the default) and fails or, worse, executes there. Both alerts need the routing line.

No flatten and no position gate. A repainting or fast-firing indicator can stack entries. Use flatten_first=true for reversal systems or require_market_position=flat for one-shot entries.

Testing on Live. Link Demo and prove the loop there first. The pipeline is identical.

Assuming a green row means a resting order. Tradovate can late-reject after acceptance (price limits are the usual cause). CrossTrade flips the row to a yellow warning with the reason when that happens — glance back after the first few live signals.

What's Next

Add richer exits (scale-outs, trailing, breakeven) → Order Types and Exits on Tradovate

Scale to multiple accountsManaging Multiple Tradovate Accounts

The full field-by-field referenceDestinations: NinjaTrader vs Tradovate