Automating TradingView Indicators
How to turn indicator buy/sell signals into automated NinjaTrader trades.
This guide will start with the assumption that the indicator you're using provides valid Buy and Sell signals. Some indicators do not, and there is a different approach to automating those indicators vs. ones that provide clear signals.
Why Indicators Are Often Easier
TradingView indicators don't carry the baggage that strategies do. There's no requirement for offsetting actions, no backtesting constraints forcing exits to match entries, and no ambiguity about whether a signal is an entry or an exit.
With an indicator, you define exactly what happens: this condition fires a BUY alert, that condition fires a SELL alert. You control both independently. The tradeoff is that you don't get TradingView's dynamic strategy variables ({{strategy.order.action}}, {{strategy.order.contracts}}), so you'll hardcode the action and quantity in each alert. For most setups, this is a feature, not a limitation — you know exactly what each alert will do because you wrote it explicitly.
Indicators also support some dynamic variables: {{close}}, {{open}}, {{high}}, {{low}}, and {{ticker}}. These can be useful for setting limit prices relative to the previous bar's price action or replacing the need to hard code your intrument. (i.e. instrument={{ticker}}; )
The Setup: Two Alerts, Two Directions
Unlike strategies (which use a single alert with dynamic variables for both entries and exits), indicators typically require separate alerts for each direction.
BUY Alert (action=buy;)
key=your-secret-key;
command=PLACE;
account=Sim101;
instrument=ES1!;
action=buy;
qty=1;
order_type=market;
tif=day;
flatten_first=true;SELL Alert (action=sell;)
The only difference between these two is the action field. Each alert is tied to a different condition in your indicator. One fires on the buy signal, the other on the sell signal.
flatten_first=true; is doing important work here. When the BUY alert fires, it will close any existing short position before opening the long. When the SELL alert fires, it will close any existing long position before opening the short. This gives you clean stop-and-reverse behavior without needing Strategy Sync.
Setting Up the Alert Conditions
To keep this article short and direct, we are not including all the images associated with each step. Please see our other more detailed guide on TradingView Alerts - Here
Open a chart with your indicator applied. Create a new alert and set the Condition to your indicator's signal. Most trading indicators expose their buy/sell signals in the condition dropdown. You'll see entries like "Buy Signal" or "Long Entry" depending on how the indicator author named them.

Create one alert for the buy condition and a separate alert for the sell condition. Each gets its own payload (as shown above), its own condition, and the same webhook URL.
If your indicator doesn't expose discrete buy/sell conditions in the alert dropdown, it may only draw visual signals (arrows, labels) on the chart after the fact. These after-the-fact drawn labels often can't be used as real-time alert triggers. Check with the indicator's author or documentation to confirm that real-time alerting is supported.

Tip: Set both alerts to fire on "Every time the condition is met" rather than "Once." You want the alert to fire every time the signal triggers, not just the first time.
Adding Exit Management
With the basic setup above, your exits happen when the opposing signal fires (BUY closes a short and opens a long, SELL closes a long and opens a short). That's stop-and-reverse behavior. If you want more control over exits, you have three options:
Option A: ATM Strategy (Fixed Brackets)
Add an ATM template for predefined stop loss and profit target levels:
The ATM template is saved in NinjaTrader and contains your TP/SL levels. CrossTrade just references it by name. Remember: the qty must match the contract count saved in the ATM template or NT8 will silently fail.
Always use flatten_first=true; with ATMs to prevent orphaned bracket orders from the previous trade.
Option B: Payload Brackets (Dynamic or Fixed)
Add take_profit and stop_loss directly in the alert message:
Tick and percentage values are offset from the fill price. You can also use absolute price levels, dollar values, or TradingView variables like {{close}} for dynamic pricing. See the Bracket Orders and Percentage and Tick Prices docs for all supported formats.
As of v1.12.0, bracket orders on limit and stop entries use wait-for-fill behavior — the TP/SL brackets aren't submitted until the entry order actually fills.
Option C: Let the Indicator Handle Exits
Create a third alert (or fourth, one per direction) that fires a CLOSEPOSITION or FLATTEN command when the indicator signals an exit:
This is useful when your indicator has distinct exit conditions that are separate from the opposing entry signal.
Adding Position Protection
Since indicators don't have Strategy Sync (that's a strategy-only feature), you protect your positions with these tools:
Prevent Duplicate Entries
require_market_position=flat; blocks any alert unless the account is flat in the specified instrument. Add this to your entry alerts to ensure you never stack positions:
Note: when using require_market_position=flat; without flatten_first, the alert is rejected if a position exists — it doesn't close the position first. If you want to allow reversals (close existing + open new), use flatten_first=true; instead. If you want to only enter when completely flat and skip any signal that comes while you're in a trade, use require_market_position=flat; without flatten_first.
For a long-only strategy where you only want to enter when flat or already long:
For a short-only strategy:
Limit Simultaneous Positions
max_positions=1; blocks alerts if you already have any position open on the account, regardless of instrument. Use this if you only want one trade active at a time across your entire account.
Restrict Trading Hours
Add trading_window=09:30-16:00 ET; to limit when alerts are accepted. Alerts outside the window are silently dropped. This is set per-alert in the payload. For account-level windows, configure them in the Account Manager settings.
Sending to Multiple Accounts
If you want the same indicator signal to place trades on multiple accounts (common for prop firm traders), list them comma-separated:
Each account receives the same order independently. See the Multi-Account Placement docs for details on per-account quantity overrides and other options.
Alternatively, use the Trade Copier for more complex multi-account setups with position sizing ratios and instrument mapping.
Common Indicator Automation Mistakes
The indicator draws signals after the fact. Some indicators calculate and draw buy/sell signals retroactively when the underlying logic recalculates. These signals look great on the chart but can't be used for real-time alerting. If your alert never fires despite signals appearing on the chart, this is likely the cause. This is whats more commonly known as 'Repainting' and can mislead a lot of new traders. Check out this guide on Repainting if you want to learn more.
Multiple alerts firing on the same condition. If your indicator's buy condition remains true across multiple bars, you'll get an alert on every bar. Use require_market_position=flat; to block subsequent entries while you're already in a position, or set the alert to "Once per bar close" instead of "Every time."
Forgetting to update contract months. If you're using hardcoded contract months (e.g., instrument=ES 06-25;), you need to update them at rollover. Using continuous contract symbols (ES1!, NQ1!, MNQ1!) avoids this; CrossTrade auto-converts them to whatever format your NinjaTrader account expects.
Mixing up alert conditions. If you accidentally assign the SELL payload to the BUY condition (or vice versa), you'll get inverted trades. Double-check that each alert's condition matches its payload action.
Related Guides:
Guide 1: Your First Automated Trade — start here if you haven't sent a working alert yet
Guide 2: Automating a TradingView Strategy — if you're using a strategy() script with dynamic variables
Guide 5: Exit Management — ATMs, brackets, and hybrid exit approaches
Reference Docs:
Last updated