POST Disable Strategy
Pause a running strategy without closing positions
POST /v1/api/accounts/{account}/strategies/{strategyId}/disable
Pauses a NinjaScript strategy. NT8 stops routing OnBarUpdate calls; any open position remains in place; pending orders may be cancelled by NT8's lifecycle rules. The strategy stays attached to its account or chart and can be resumed with EnableStrategy.
Use this when you want a strategy to stop generating new entries but want to keep its existing position open. To also flatten the position and remove the strategy entirely, use CloseStrategy instead.
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. |
strategyId | string | Required | ID of the strategy as returned by ListStrategies or ListAllStrategies. |
Code Examples
- Python
- JavaScript
- cURL
import requests
token = 'my-secret-token'
url = "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/370780512/disable"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
try:
response = requests.post(url, headers=headers, json={})
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/370780512/disable";
fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({})
})
.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/370780512/disable" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{}'
Response
- 200
- 404
{
"strategyId": "370780512",
"account": "Sim101",
"hostMode": "chart",
"wasEnabled": true,
"isEnabled": false,
"state": "Realtime",
"success": true
}
{
"success": false,
"error": "strategy_not_found",
"detail": "No strategy with id '370780512' on account 'Sim101'. Use ListStrategies or ListAllStrategies to discover valid ids."
}
WebSocket API
This request can also be made over the WebSocket API. The account and strategyId path parameters are passed inside args.
{
"action": "rpc",
"id": "my-request-id",
"api": "DisableStrategy",
"args": {
"account": "Sim101",
"strategyId": "370780512"
}
}