Skip to main content

POST Start Strategy

Start a NinjaScript strategy from disk NT8​

Starts a compiled NinjaScript strategy (full C# Strategy class) from 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).

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.

Endpoint​

POST /v1/api/accounts/{account}/strategies/start

Headers​

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Path parameters​

NameTypeRequiredDescription
accountstringRequiredName of the NT8 account that owns the strategy (e.g. Sim101).

Body parameters​

NameTypeRequiredDescription
strategyClassstringRequiredBare 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.
instrumentstringRequiredFull NT8 instrument name (e.g. ES 12-26).
modestringOptionalaccount (default — headless deploy, no chart visualization; alias headless is also accepted) or chart (attach to a visible chart, auto-opens one if needed).
periodTypestringOptionalNT8 BarsPeriodType. One of Minute (default), Tick, Second, Day, Volume, Range.
periodintOptionalPeriod value (default 5 — interpretation depends on periodType).
parametersobjectOptionalStrategy parameter overrides. Keys are public property names on the NinjaScript class (for example, FastPeriod=9, SlowPeriod=21).

Code examples​

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 12-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}")

Response​

{
"success": true,
"strategyId": "370780512",
"deploymentId": "dep_dbb63c44814f",
"account": "Sim101",
"strategyClass": "MyEmaStrategy",
"instrument": "ES 12-26",
"hostMode": "chart",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"state": "Realtime",
"reachedActive": true,
"trace": [
"resolved account: Sim101"
]
}

Success field types​

FieldTypeDescription
success, reachedActivebooleanRequest outcome and whether the strategy reached an active state.
strategyId, deploymentId, account, strategyClass, instrumentstringDeployment identifiers and target.
hostMode, mode, periodType, statestringHosting mode, bar type and reached state.
periodintegerBar-period size.
tracearray of stringsDeployment trace messages.

Platform nuances​

Available in CrossTrade NT8 Add-On v1.13.0+.

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 12-26",
"mode": "chart",
"periodType": "Minute",
"period": 5,
"parameters": {"FastPeriod": 9, "SlowPeriod": 21}
}
}