# NinjaTrader API: NinjaScript, ATI and the REST route

URL: https://fincodelabs.com/en/blog/ninjatrader-api · Publisher: Fincode (Fincode Yazılım ve Teknoloji A.Ş.), Istanbul, Turkey · Category: Stocks, forex and broker APIs · Published: 2026-11-06 · Updated: 2026-11-06

Does NinjaTrader have an API? NinjaScript, ATI files and the REST Trade API compared, Python options, TradingView routes, how to hire a NinjaScript developer.

**Short answer:** Yes, but the **NinjaTrader API** is three different things: NinjaScript, the C# framework that runs only inside the NinjaTrader 8 desktop on Windows; ATI, which takes order commands from other programs through files or a DLL and, by NinjaTrader's own note, is not a full brokerage or market data API; and the REST and WebSocket Trade API, whose hosts still carry the Tradovate name. As of 5 November 2026 no official Python SDK was seen for any of them, and TradingView alerts reach the desktop only through software you add.

NinjaTrader API documentation is split across three sites, all read on 5 November 2026. The file sample below ran on synthetic alerts; NinjaTrader 8 was not available here, so nothing ran in the platform or on a Sim account. Futures carry leverage and automated orders can lose money quickly. Rules depend on your country, account types and API access vary, and no broker is recommended, ranked or linked with a referral.

Section 3 of TradingView's [Terms of Use](https://www.tradingview.com/policies/), read on 5 November 2026, licenses charts, alerts and webhooks for display-only use, lists automated trading and automated order generation among prohibited uses, and bars third-party products built for that purpose. That matters for any TradingView route below; it is a contract question between you and TradingView, so read the terms and take legal advice.

## Does NinjaTrader have an API? Three answers

Yes, three of them, and where your code must run decides which.

**NinjaTrader's programming interfaces, official pages read 5 November 2026**

| Item | NinjaScript | ATI | Trade and Market Data APIs |
| --- | --- | --- | --- |
| Language | C# | Any program that writes text files, or loads the ATI DLL | Any language with HTTP and WebSocket; Swagger definitions |
| Runs where | In-process, NinjaTrader 8 desktop, Windows | Your program, alongside the running desktop | Your own server, calling NinjaTrader's hosts |
| Market data | Live and historical | Files: none. DLL: last, bid and ask for a subscribed instrument | Quotes, depth and charts over a separate WebSocket host |
| Docs | [NinjaScript](https://docs.ninjatrader.com/ninjascript) | [Help guide](https://static.ninjatrader.com/support/helpGuides/nt8/automated_trading_interface_at.htm) | [Trade API](https://docs.ninjatrader.com/api) |

The developer site also lists Web Trader, for JavaScript tools, and an [MCP server](https://docs.ninjatrader.com/mcp) for AI agents, neither covered here. NinjaScript does not run on the web platform, and [NinjaTrader's blog](https://ninjatrader.com/futures/blogs/whats-new-in-ninjatrader-web/) of 26 October 2026 says the new NinjaTrader Web, with TradingView-powered charts, became the default browser version on 20 October 2026. Those charts are not an alert route.

## NinjaScript: C# inside the desktop

NinjaScript is the route for logic that lives in the platform: it compiles to code running in-process with direct access to data, charts, accounts and order submission.

You can write indicators, strategies, AddOns, drawing tools, bars types, chart styles and optimizers. The docs say to compile custom indicators in the NinjaScript Editor, even if you write them elsewhere. AddOns can reach further than strategies: the [Account class](https://docs.ninjatrader.com/ninjascript/account_class) documents `CreateOrder()`, `Submit()`, `Cancel()` and account events. The desktop must be running, on Windows, and a fault in your code is a fault in your trading platform.

## ATI: what the Automated Trading Interface does and does not do

ATI carries order commands from an outside program into the running desktop, and the help guide says plainly that it is not a full brokerage or market data API.

**ATI commands, from Commands and Valid Parameters, read 5 November 2026**

| Command | Effect |
| --- | --- |
| `PLACE`, `CHANGE`, `CANCEL` | Place, change or cancel one order; `PLACE` can start an ATM strategy |
| `CLOSEPOSITION`, `REVERSEPOSITION`, `CLOSESTRATEGY` | Act on one position or ATM strategy |
| `CANCELALLORDERS` | Cancels all active orders across all accounts and broker connections |
| `FLATTENEVERYTHING` | Cancels all active orders and flattens all positions across all accounts and connections |

Never let an incoming alert choose the last two. Turn the interface on under Tools, Options, Automated trading interface, where you also set the default account; a missing account in a command falls back to it. The file interface has its own failure points:

- **Location and names.** Files go in `My Documents\<NinjaTrader Folder>\incoming` as `oif*.txt`. Reusing a name in rapid succession risks a lock and an unprocessed file, and the option *Ignore duplicate OIF files* drops repeats of a name within a session.
- **Move, do not copy.** The guide warns that copying into `incoming` can cause locking.
- **Feedback is thin.** State files appear in `outgoing` only for orders given an order ID, in the form state, filled amount, average price, and that folder is emptied when the platform restarts. The pages read describe no error file for a malformed line, and the DLL page points to the Log tab for errors, so treat a missing state file after a timeout as an unknown result and check the platform before you resend.
- **Instrument names.** The NinjaScript docs give the full name form as ES 09-16; the ATI pages show ES 0914 Globex in a file name and say CLOSEPOSITION takes the name with the exchange. Confirm the form on Sim.

> **Hypothetical example.** `PLACE;Sim101;MES 12-26;BUY;1;MARKET;;;DAY;;alert-0001;;` reads, in the documented order: command, account, instrument, action, quantity, order type, limit price, stop price, time in force, OCO ID, order ID, strategy, strategy ID. If it works, `outgoing\alert-0001.txt` would hold a line such as `Filled;1;5000.25`; the [state definitions page](https://static.ninjatrader.com/support/helpGuides/nt8/order_state_definitions.htm) spells states that way, and the file's exact spelling was not confirmed.

The [DLL functions](https://static.ninjatrader.com/support/helpGuides/nt8/functions.htm) give richer feedback, including `OrderStatus()`, `MarketPosition()` and `MarketData()`. One trap from the [initialization page](https://static.ninjatrader.com/support/helpGuides/nt8/initialization.htm): the interface binds to the first account name used, so if you start with the default account by passing an empty string, later calls naming that account return invalid information.

## NinjaTrader API Python: what exists

No official Python SDK was seen on 5 November 2026: the Trade API points to JavaScript and C# examples, NinjaScript is C#, and Python reaches the desktop as a program writing ATI files or loading the DLL, or through custom C# you add.

For the REST route, the [API product page](https://developer.ninjatrader.com/products/api) says the Swagger definitions can generate code in nearly any language; that was not run here. The DLL route was not run either. Its page names both NTDirect.dll and NinjaTrader.Client.DLL, and a NinjaTrader support reply of July 2023, read only in search results because the old forum no longer opens, says only NinjaTrader.Client.dll is usable from 8.0.28.0, so confirm with support. The file route needs only the standard library, tested on 5 November 2026 with Python 3.11 in a temporary folder:

```python
import os, re
from pathlib import Path

ACCOUNT = "Sim101"                       # stay on the simulation account while testing
LIMITS = {"MES 12-26": 2}                # your instruments and maximum quantities (hypothetical)

def place_line(alert):
    """Build one PLACE line. Only PLACE is ever built."""
    instrument, qty = alert["instrument"], int(alert["qty"])
    action = alert["action"].upper()
    if action not in ("BUY", "SELL"):
        raise ValueError(f"bad action {action}")
    if not 1 <= qty <= LIMITS.get(instrument, 0):
        raise ValueError(f"{instrument} qty {qty} is outside your limits")
    order_id = alert["id"]
    if not re.fullmatch(r"[A-Za-z0-9_-]{1,40}", order_id):
        raise ValueError("bad order id")
    fields = ["PLACE", ACCOUNT, instrument, action, str(qty), "MARKET",
              "", "", "DAY", "", order_id, "", ""]
    return ";".join(fields)

def submit(line, seq, root):
    """Move the finished file into incoming/; never copy."""
    root = Path(root)
    tmp = root / f"oif{seq}.tmp"
    tmp.write_text(line + "\n", encoding="ascii")
    os.replace(tmp, root / "incoming" / f"oif{seq}.txt")

def order_state(order_id, root):
    """Read outgoing/<orderId>.txt: state;filled;average price. None until it exists."""
    path = Path(root) / "outgoing" / f"{order_id}.txt"
    if not path.exists():
        return None
    state, filled, avg = path.read_text(encoding="ascii").strip().split(";")
    return state, int(filled), float(avg)
```

Output with synthetic alerts and a state file:

```
PLACE;Sim101;MES 12-26;BUY;1;MARKET;;;DAY;;alert-0001;;
state before fill: None
state after a synthetic outgoing file: ('Filled', 1, 5000.25)
refused: bad action FLATTENEVERYTHING
refused: MES 12-26 qty 9 is outside your limits
refused: bad order id
```

This proves the text format against the documented field order, not the platform's behavior. Run it on Sim first and keep account and instrument limits outside the alert. The docs require a unique order ID but do not say what a repeat does, so keep your own duplicate check; the wider test plan is in [how to test trading bots](https://fincodelabs.com/en/blog/how-to-test-trading-bots).

## TradingView to NinjaTrader: routes that can be built

The desktop documents no inbound webhook, so a TradingView webhook has to land on software you add, and the choice is about where the public endpoint sits.

**Getting a TradingView webhook to the desktop**

| Route | How it works | Main risk |
| --- | --- | --- |
| Receiver on the same Windows machine | Accepts the webhook and writes OIF commands | A public port on the machine that holds your trading platform |
| Public relay plus local agent | A small server queues alerts; a local agent collects them outbound and writes OIF commands | Delay and a queue to keep healthy |
| NinjaScript AddOn | C# inside the platform collects alerts and calls `Submit()` | Your network code shares the platform's process |
| Vendor app | The Ecosystem directory lists webhook automation products | A third party in your order path; not assessed here |

TradingView sends only to ports 80 and 443, requires two-factor authentication and cancels a request after 3 seconds, so reply first and write the file afterward; the pattern is in [TradingView webhook bot](https://fincodelabs.com/en/blog/tradingview-webhook-bot).

Clicking orders on the chart is separate: NinjaTrader's [prop guide](https://prop.ninjatrader.com/blogs/connect-prop-account-to-tradingview/) of 12 August 2026 shows NinjaTrader in TradingView's broker list, and no page read describes alerts placing orders through that link.

## The REST route: Trade API in short

The Trade API suits server-side software with no Windows desktop and is separate from NinjaScript and ATI.

`docs.ninjatrader.com/api` holds the newer pages. Requests go to hosts such as `demo.tradovateapi.com`, and market data uses its own token and WebSocket host. Access requirements, reported fees, rate limits and the license are covered in [TradingView to Tradovate](https://fincodelabs.com/en/blog/tradingview-to-tradovate), and general order handling in [broker API integration](https://fincodelabs.com/en/blog/broker-api-integration-fix-rest).

## NinjaScript developer: what to specify before hiring

Hire against a written rule document and a list of deliverables, with the source code as the first item. Fincode sells custom trading software, so this guide is not neutral on that point.

**What to ask a NinjaTrader developer**

| Item | What to require | Why |
| --- | --- | --- |
| Source or assembly | Source files in the contract, not only a DLL | The [export page](https://docs.ninjatrader.com/ninjascript/export) describes source files others can edit and assemblies that hide the code, so a DLL alone leaves you unable to fix or move it |
| Protection and licensing | Who holds any Agile.NET protection or vendor license, and what happens if the seller disappears | [User-based licensing](https://docs.ninjatrader.com/ninjascript/user_based_licensing) ties a product to your NinjaTrader login under the vendor's control |
| Acceptance tests on Sim | Restart with an open position, partial fill, lost connection, contract roll, kill switch | They test behavior, which a developer can answer for |

**Red flags:** profit screenshots or backtest returns offered as proof; a promised win rate; compiled files only, with no way to get the source; a request for your login or for control of your account. The [Ecosystem](https://ninjatraderecosystem.com/) site carries the NFA Rule 2-29(c) warning that hypothetical results have inherent limitations and may be prepared with hindsight, so judge the software, not the equity curve.

The Ecosystem's [programming services category](https://ninjatraderecosystem.com/search-results/?fwp_category=programming-services) showed 67 listings on 5 November 2026; no statement of how they are vetted was seen, and listing is not an endorsement here.

Fincode quotes only through its [algorithmic trading](https://fincodelabs.com/en/services/algorithmic-trading) page, from rules you wrote, and supplies no strategies. That page is written around crypto trading bots and no prior NinjaScript project is claimed, so ask whether your case fits.

## Which rules apply to automated NinjaTrader orders?

Your country, your broker's terms and any prop firm's rules apply whichever route you choose, and none of the code above changes them.

- **One account, one person.** These routes suit your own account and your own rules. Sending one alert to other people's accounts can amount to copy trading or account management, which can be licensed activity, and the [API license](https://api.tradovate.com/) of September 2026 bars an integration from controlling customer accounts.
- **Prop firms.** Their rules bind you, so ask before automating.
- **Readers in Turkey.** Leveraged FX with foreign firms falls under separate rules: the Capital Markets Board (SPK) [said on 23 February 2023](https://spk.gov.tr/duyurular/basin-duyurulari/2023/izinsiz-kaldiracli-islemlere-iliskin-basin-duyurusu) that residents may carry out such trades only through firms it has authorized, and offering them without authorization is a crime under Article 109(2) of [Law No. 6362](https://www.mevzuat.gov.tr/mevzuatmetin/1.5.6362.pdf). Article 99(4) lets SPK block such sites, and [Communiqué III-37.1](https://mevzuat.spk.gov.tr/api/Mevzuat/File/130) Articles 9 and 27 define activity aimed at residents and cap leverage at authorized firms. Article 9 reaches any investment service from a firm abroad, but no text read settles exchange-traded futures through a foreign broker, so take advice.

## Frequently asked questions

### Does NinjaTrader have a Python API?

No official Python SDK was seen on 5 November 2026. Python can write ATI order files or call the REST Trade API with generated or hand-written code; the ATI DLL route was not tested here.

### Does NinjaScript run on Mac or in NinjaTrader Web?

The NinjaScript overview read on 5 November 2026 says it runs only in the NinjaTrader 8 desktop application on Windows and is not used for the web trader.

### Can TradingView alerts trigger NinjaTrader orders?

Only through software you add, such as a receiver that writes ATI files or an AddOn, because no inbound webhook is documented for the desktop. TradingView's terms restrict this use, so read them first.

### What should a NinjaScript developer deliver?

Source files, a build you can compile yourself, a Sim test report covering failures, and written notes on any licensing or protection. Results of trading are not a deliverable anyone can promise.

## Sources

- [NinjaTrader Developer Docs: NinjaScript overview](https://docs.ninjatrader.com/ninjascript)
- [NinjaTrader 8 Help Guide: Automated Trading Interface (ATI)](https://static.ninjatrader.com/support/helpGuides/nt8/automated_trading_interface_at.htm)
- [NinjaTrader 8 Help Guide: Order Instruction Files (OIF)](https://static.ninjatrader.com/support/helpGuides/nt8/order_instruction_files_oif.htm)
- [NinjaTrader 8 Help Guide: Commands and Valid Parameters](https://static.ninjatrader.com/support/helpGuides/nt8/commands_and_valid_parameters.htm)
- [NinjaTrader 8 Help Guide: Information Update Files](https://static.ninjatrader.com/support/helpGuides/nt8/information_update_files.htm)
- [NinjaTrader 8 Help Guide: Automated trading interface settings](https://static.ninjatrader.com/support/helpGuides/nt8/options_ati.htm)
- [NinjaTrader 8 Help Guide: DLL Interface](https://static.ninjatrader.com/support/helpGuides/nt8/dll_interface.htm)
- [NinjaTrader Developer Docs: Instrument FullName](https://docs.ninjatrader.com/ninjascript/fullname)
- [NinjaTrader Developer Docs: Developing Outside of the NinjaScript Editor](https://docs.ninjatrader.com/ninjascript/developing_outside_of_the_ninj)
- [NinjaTrader Developer Docs: Protection DLL Security](https://docs.ninjatrader.com/ninjascript/protection_dll_security)
- [NinjaTrader Developer Docs: Market Data API, Authentication and Access](https://docs.ninjatrader.com/market-data/authentication)
- [NinjaTrader Developer Community: API product page (Swagger, code generation)](https://developer.ninjatrader.com/products/api)
- [TradingView: How to configure webhook alerts](https://www.tradingview.com/support/solutions/43000529348-how-to-configure-webhook-alerts/)
- [TradingView: Terms of Use, section 3 (read 5 November 2026)](https://www.tradingview.com/policies/)
- [SPK (Capital Markets Board): Press notice on unauthorized leveraged transactions, 23 February 2023 (Turkish)](https://spk.gov.tr/duyurular/basin-duyurulari/2023/izinsiz-kaldiracli-islemlere-iliskin-basin-duyurusu)

> This guide is general information about software and markets, not investment, legal or tax advice. Automated trading can lose money, past or backtested performance does not guarantee future results, and the rules that apply depend on your jurisdiction and your exchange's terms. Sources, checks and corrections: see the [editorial policy](https://fincodelabs.com/en/editorial-policy).

---

Published by Fincode (Fincode Yazılım ve Teknoloji A.Ş.), a software company in Istanbul, Turkey: https://fincodelabs.com/en/blog/ninjatrader-api

Cite as: Fincode, "NinjaTrader API: NinjaScript, ATI and the REST route", updated November 6, 2026, https://fincodelabs.com/en/blog/ninjatrader-api
