POST Start Strategy
Start a NinjaScript strategy from disk
POST /v1/api/accounts/{account}/strategies/start
Instantiates a NinjaScript strategy (full C# Strategy class) that's compiled into NinjaTrader.Custom.dll and attaches it to NT8. Choose mode=account for a headless deploy (no chart visualization) or mode=chart to attach to a visible chart for the instrument (auto-opens one if absent).
:::info NinjaScript vs ATM
This endpoint operates on NinjaScript strategies — the .cs class files under Documents\NinjaTrader 8\bin\Custom\Strategies\. It does not start an ATM (Advanced Trade Management) strategy — those are predefined order management templates queried via GET ATM Templates and attached to individual orders rather than instantiated as standalone strategies.
:::
Available in CrossTrade Add-On v1.13.0+.
Headers
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
account | string | Required | Name of the NT8 account that owns the strategy (e.g. Sim101). |
Body Parameters
| Name | Type | Required | Description |
|---|---|---|---|
strategyClass | string | Required | Bare NinjaScript class name as it appears in the .cs file under Documents\NinjaTrader 8\bin\Custom\Strategies (e.g. MyEmaStrategy). Must already be compiled into NinjaTrader.Custom.dll. |
instrument | string | Required | Full NT8 instrument name (e.g. ES 06-26). |
mode | string | Optional | account (default — headless deploy, no chart visualization; alias headless is also accepted) or chart (attach to a visible chart, auto-opens one if needed). |
periodType | string | Optional | NT8 BarsPeriodType. One of Minute (default), Tick, Second, Day, Volume, Range. |
period | integer | Optional | Period value (default 5 — interpretation depends on periodType). |
parameters | object | Optional | Strategy parameter overrides. Keys are public property names on the NinjaScript class (for example, FastPeriod=9, SlowPeriod=21). |
Code Examples
- Python
- JavaScript
- cURL
import requests
token = 'my-secret-token'
url = "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/start"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
data = {
"strategyClass": "MyEmaStrategy",
"instrument": "ES 06-26",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"parameters": {"FastPeriod": 9, "SlowPeriod": 21}
}
try:
response = requests.post(url, headers=headers, json=data)
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")
const token = 'my-secret-token';
const url = "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/start";
fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
strategyClass: "MyEmaStrategy",
instrument: "ES 06-26",
mode: "chart",
periodType: "Minute",
period: 5,
parameters: { FastPeriod: 9, SlowPeriod: 21 }
})
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
TOKEN="my-secret-token"
curl -X POST "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/start" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"strategyClass": "MyEmaStrategy",
"instrument": "ES 06-26",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"parameters": {"FastPeriod": 9, "SlowPeriod": 21}
}'
Response
- 200
- 400
- 404
- 409
{
"success": true,
"strategyId": "370780512",
"deploymentId": "dep_dbb63c44814f",
"account": "Sim101",
"strategyClass": "MyEmaStrategy",
"instrument": "ES 06-26",
"hostMode": "chart",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"state": "Realtime",
"reachedActive": true
}
{
"success": false,
"error": "missing_arg",
"detail": "Required field: 'strategyClass'. Use the bare NinjaScript class name (e.g. 'MyEmaStrategy') as it appears under Documents\\NinjaTrader 8\\bin\\Custom\\Strategies\\."
}
{
"success": false,
"error": "strategy_class_not_found",
"detail": "strategy class 'MyEmaStrategy' not found. Compile the .cs file (F5 in NinjaScript Editor) before calling Start."
}
{
"success": false,
"error": "chart_not_found",
"detail": "Triggered the chart-open path but a window for 'ES 06-26' didn't appear within the deploy window. Retry in ~10 seconds or use mode:'account' to deploy headless."
}
WebSocket API
This request can also be made over the WebSocket API. The account is passed inside args alongside the body fields.
{
"action": "rpc",
"id": "my-request-id",
"api": "StartStrategy",
"args": {
"account": "Sim101",
"strategyClass": "MyEmaStrategy",
"instrument": "ES 06-26",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"parameters": {"FastPeriod": 9, "SlowPeriod": 21}
}
}