/ninjatrader:pretrade-riskfrom NinjaTrader
Sizes futures trades from risk-per-trade (% of netLiq), stop distance (ATR-based or explicit), and contract specs. Proposes an OCO bracket (stop + target at R-multiple) for the chosen entry. Pending-qty-aware — includes existing position and open orders. Flags exceeds_daily_loss_budget, exceeds_max_contracts, stop_too_wide_for_risk_budget.
Ships in NinjaTrader. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill turns "I want to buy ES" into a sized, bracketed, risk-budgeted proposal. It uses two scripts and one reference. It never emits order payloads. It always leaves the place/modify decision to the user.
Demo (simulation) and live are two separate MCP servers. Account names are unique to one server. Once the workflow resolves an account on a server, keep every downstream call on that same server. The rule covers my_portfolio, market_snapshot, place_order, create_alert, the history tools, and any other tool. Cross-routing fails or hits the wrong environment.
Tool names below are bare. The NinjaTrader MCP server provides them. Your client adds its own prefix. See AGENTS.md at the repo root.
my_portfolio — netLiq, existing position, and pending order qty.
Prune with fields=["account.netLiq","positions[].symbol","positions[].netPos","workingOrders[].symbol","workingOrders[].action","workingOrders[].quantity"].market_snapshot — last price, tickSize, valuePerPoint for the
symbol. Prune with
fields=["snapshots[].symbol","snapshots[].lastPrice","snapshots[].tickSize","snapshots[].valuePerPoint","snapshots[].initialMargin"].risk_settings — daily loss limit and max contracts per order.estimate_order — the server's read-only pre-trade feasibility
gate. Run it in every workflow outcome. Never skip it.describe — call with topic='place_order_examples' to confirm
the bracket sign convention before submission.If the user gave a bare product code ("ES"), resolve it with the contract-intel skill first. This skill expects a specific contract symbol (like ESU6) downstream.
Call these MCP tools in parallel where possible:
my_portfolio → account.netLiq, existing
position's netPos, sum of pending Buy+Sell orders for the symbol.
Prune with fields=["account.netLiq","positions[].symbol","positions[].netPos","workingOrders[].symbol","workingOrders[].action","workingOrders[].quantity"].market_snapshot(symbols=[sym]) →
lastPrice (for entry), tickSize, valuePerPoint.
Prune with fields=["snapshots[].symbol","snapshots[].lastPrice","snapshots[].tickSize","snapshots[].valuePerPoint","snapshots[].initialMargin"].risk_settings(account=...) →
dailyLossAutoLiq (absolute value). risk_settings has no
per-order contract-count cap — source that limit from
estimate_order's pre-trade validation instead.Also run market-context's atr.py on recent bars of the symbol to get the ATR in points. Default is Daily bars, 14-period ATR.
python3 scripts/size.py \
--netliq 100000 \
--risk-pct 1.0 \
--atr 6.0 \
--value-per-point 50 \
--daily-loss-budget 500 \
--max-contracts 10 \
--existing-net-pos 0 \
--existing-pending-qty 0
Output fields used downstream:
proposed_qty → pass to bracket.py --qtystop_distance_points → pass to bracket.py --stop-distance-pointsflags[] → narrate to the user. See references/risk-rules.mdAlways pass --existing-pending-qty when non-zero so sizing matches the server-side pre-trade risk check that will evaluate the order. See references/risk-rules.md § pending-qty rule.
If proposed_qty == 0 and flag is stop_too_wide_for_risk_budget: the contract is too large for the risk budget at this stop distance. Options are: use a micro (consult contract-intel for the fungible sibling), tighten the stop, or raise --risk-pct with explicit user intent. A zero-qty answer does not skip step 5. Run the feasibility gate on the alternative you propose. If you have no alternative, run the gate on a qty=1 probe of the requested contract. This way, the server's verdict backs the honest answer.
python3 scripts/bracket.py \
--entry 7150 \
--direction long \
--stop-distance-points 9 \
--r-multiple 2.0 \
--tick-size 0.25 \
--qty 4 \
--value-per-point 50
bracket.py snaps prices to the tick grid. Output gives stop_price, target_price, and dollar-risk/payoff. A payoff_risk_ratio < 1.5 is a yellow flag. You could tighten the target or widen the stop, for fewer but better trades.
The user chooses the R-multiple. The default in examples is 2.0 for illustration. Real invocations should use the target multiple the user actually wants. The skill does not recommend a specific R-multiple. It computes the bracket prices for whatever the user asks for.
place_order — SIGNED DELTAS, not absolute pricesbracket.py emits absolute stop_price and target_price. The place_order brackets[] field expects signed deltas added to the entry working price in contract-native points. Both legs compute entryPrice + delta server-side, with no Buy/Sell sign-flip. describe(topic='place_order_examples') confirms this.
Convert before submitting:
profit_target_offset = target_price - entry_price
stop_loss_offset = stop_price - entry_price
The signs follow the trade direction:
| Direction | profitTarget | stopLoss |
|---|---|---|
| Long (Buy entry) | positive (target above entry) | negative (stop below entry) |
| Short (Sell entry) | negative (target below entry — profit when short) | positive (stop above entry — loss when short) |
Long example — Buy LMT 7250, target 7458, stop 7074:
brackets: [{ "qty": 1, "profitTarget": 208, "stopLoss": -176 }]
Short example — Sell LMT 7250, target 7042, stop 7426:
brackets: [{ "qty": 1, "profitTarget": -208, "stopLoss": 176 }]
The describe(topic='place_order_examples') text says "positive profitTarget = better, negative stopLoss = worse". That framing is correct only for longs. For shorts the signs invert because "better" (target) is below entry and "worse" (stop) is above. Do not paraphrase "positive = better". Reason from the trade direction.
Failure mode if you forget: If you send absolute prices, both legs anchor at entry + absolute. An example is profitTarget: 7458, stopLoss: 7074 on a long at 7250. The target then lands at ~14708, working but unreachable. The stop lands at ~14324, above entry on a long, so the server rejects it. The user ends up with a fill and no stop loss. Always convert.
The fill price can also differ from your limit. Better-side fills are common. The system applies the offsets to the actual fill, so the absolute bracket prices auto-anchor correctly without recomputation.
Always end with estimate_order. The server's pre-trade risk check is the authoritative answer. It is read-only and never places an order, so there is no reason to omit it:
estimate_order(
account=acct, symbol=sym, action=Buy|Sell,
quantity=proposed_qty, orderType=Market
)
This step runs in every workflow outcome, and the answer must cite its verdict:
proposed_qty == 0) with a micro alternative →
gate the alternative sizing (e.g. MES qty from the recomputed
budget).quantity=1 of the requested
contract anyway. The point is to surface the server's own block —
e.g. a futures max-order-quantity of 0 or MaxPosLimitReached —
instead of resting the answer on arithmetic alone.If feasible: false, report the reason to the user. Do not propose workarounds automatically. The server said no.
MaxPosLimitReached is dynamic, per-contract, and includes pending working orders. Two distinct sources fire under the same name. Source (a) is the account's contract whitelist: it excludes the contract or the product. Source (b) is the per-product hypothetical post-fill position (hypoLong / hypoShort / hypoExposed). It exceeds the limit once the count includes in-flight working orders. The user might have recent in-flight churn, such as just-cancelled bracket legs or just-modified working orders. In that case, the hypothetical count can run temporarily high. After the working-order state settles, a single retry is legitimate. If the rejection persists, it is a real account-config gate. Defer to the user to adjust it through Account Settings. Never silently work around it.
Once the user approves the bracket, emit complementary alert expressions for the user to submit via alerts-composer. See references/risk-rules.md, section Alert-proposal hook, for templates. Typical examples are a breakeven-trip alert and a target-approach alert.
Lead with the qty and dollar risk. Include the R:R ratio. Mention ATR for context. Example narration:
"4 ES long at 7150 with a 12-point stop (~1.5×ATR of 8): $2,400 at risk, 360% of your daily $500 budget — the trade is too big for one day's loss budget. Options: drop to 1 contract (risk $600), tighten stop to 6 points (risk $1,200, still 240% of budget), or raise daily budget explicitly before proceeding."
Or when everything fits:
"4 ES long at 7150, stop 7141, target 7168. $1,800 risk (1.8% of netLiq), $3,600 payoff at 2R target. estimate_order confirms feasible."
Or the honest zero — still grounded in the server's verdict:
"Zero ES contracts: 1% of your $9,900 netLiq is a $99 risk budget, and a 10-point ES stop risks $500 per contract. estimate_order confirms the account can't take the trade (futures max order qty is 0). MES with the same stop risks $50 per contract — 1 contract fits the budget if you want the micro."
contract-intel: contract-intel resolves "ES" → "ESU6". This
skill sizes a trade on the resolved symbol. Always run contract-intel
first when the user gave a bare code.scale-manager: pretrade-risk sizes the initial entry.
Scaling in/out of an existing position (adding on a breakout, taking
partial at target) is scale-manager's job.position-watchdog: pretrade-risk runs before the position
is live. Once filled, position-watchdog monitors health.risk-coach: this skill computes the numbers (qty, stop, target).
risk-coach judges whether the plan is behaviorally sound ("are you
trading on tilt?", "is this your third trade this hour?"). This is
a different, higher-level check.place_order is a separate step the user triggers.estimate_order rejects,
the user has to change something. Raising hidden limits is not a
fix.scripts/size.py — position-sizing math, pending-qty-aware, with
guardrail flagsscripts/bracket.py — bracket proposal (stop + target) with
tick-grid snapping and risk/payoff dollar mathreferences/risk-rules.md — guardrail taxonomy, the pending-qty
rule, default parameters, alert-proposal hook templates, and
explicit non-goals. Load it when you narrate a guardrail flag or
draft an alert-proposal hook.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub nt-ninjatrader/mcp-skills --plugin ninjatrader13 skills in this plugin
/alerts-composerTranslates natural-language alert intent into a validated Tradovate alert-DSL expression. Submits the expression via create_alert.expression. Covers 37 numeric functions across Account (netLiq, dollarOpenPL, dailyLossLimit, ...) and Contract (lastPrice, percentChange, settlementPrice, ...) entities. Also covers Position (netPos, posOpenPLUsd, posInitMarginUsd, ...) and Currency (currentRate) entities. Supports arithmetic (plus, minus, times, divide, parens), comparison (gt, gte, lt, lte, eq, neq), and top-level AND/OR/XOR logic. Validates the expression offline (subject syntax, function catalog, paren balance, flat-logic rule) before submission. Use when the user says "alert", "notify", "notify me", "watch for", "wake me when", "tell me when", "heads up when", "ping me if", "set a trigger", or "let me know if". Also use when the user asks about a sibling skill's proposed alert expression. position-watchdog, event-watch, and pretrade-risk also submit their proposed expressions through this skill./chart-renderThis skill renders three static PNG charts, with Matplotlib. Candlestick charts, with VWAP, fill-marker, and price-level overlays. Horizontal volume-profile histograms, with POC, VAH, and VAL lines. Cumulative-P&L equity curves, with optional drawdown shading. Chart data comes from market_history bars, fill_history fills, market-context analytics, and trade-journal round-trip trades. Use it when the user asks to "chart", "plot", "draw", "visualize", or "render". Also use it when the user wants a picture of the bars, fills, equity, or profile. Also use it for a qualified "show", such as "show the chart", "show me the bars", or "show my equity curve". A bare "show me my positions" is NOT a chart request. Route it to position-watchdog or my_portfolio. It produces PNG output at a specified path. It is never interactive. This skill requires matplotlib (install with `pip install matplotlib`)./contract-intelSymbol discovery, front-month resolution, rollover-imminence classification, and product-family awareness (full ↔ micro pairs like ES/MES) for futures contracts. Resolves bare product codes like "ES" or "NQ" to the actual tradeable front-month contract (e.g., ESU6) by open-interest rank across maturities. Classifies rollover status as not_imminent / approaching / imminent / rolled, with calendar-spread candidate flag when both legs are liquid. Use when the user asks "what symbol", "which contract to trade", "front month", "roll" or "rollover", "micro" or "full", or "calendar spread". Also use when the user gives a bare product code (ES, NQ, YM, CL, GC, etc.) without a maturity. Also handles product-family metadata via search_contracts includeFamilySiblings flag./correlation-hedgeCompute historical Pearson correlation and OLS regression beta between two futures symbols, on log-returns. Turn that result into a dollar-neutral hedge proposal for an open position. Covers cross-underlying relationships — ES vs NQ, CL vs NG, GC vs SI, bonds vs stocks, and currencies vs DX. For same-underlying siblings like ES/MES, use contract-intel instead. Produces sized hedge candidates with raw qty, rounded qty, residual exposure percentage, and coverage percentage. Always informational — never emits order payloads. Use when the user asks about "correlation between X and Y", "hedge this", "how do I hedge", "what could I short to offset", "beta", "X vs Y correlation", "cross-asset", "co-move", "correlated exposure", or "am I already long the market"./event-watchCovers a high-volatility economic event calendar — FOMC, CPI, NFP, EIA, and OPEC. Also covers earnings-season awareness and session-boundary context — globex open, NY cash open, settlement, and EIA release windows. Reports upcoming events and filters them by the user's current positions. Explains a move after it happens (for example, "ES +24pts in 8min matches the hot CPI print"). Computes historical reaction-size magnitudes from prior releases. Proposes reaction-window bracket alerts via alerts-composer. It is strictly reactive, with no timer-based push. Use when the user asks "what's coming up", "economic calendar", "why did it move", "NY cash open", or "session open". Also use when the user names a specific event — CPI, FOMC, NFP, EIA, OPEC, or earnings./market-contextComputes market metrics for futures from market_history output. Metrics include session VWAP, POC/VAH/VAL (value area), bar-level delta, cumulative delta, order-flow imbalance, ATR(N), realized volatility, and cross-symbol relative strength. It produces narrative summaries of market structure and the volatility regime. Use when the user asks about VWAP, POC, market profile, or value area. Also use for ATR, realized volatility, delta, cumulative delta, or order-flow imbalance. Also use for the volatility regime, or for intra-day relative strength between related symbols (e.g., ES vs NQ vs RTY). position-watchdog, pretrade-risk, scale-manager, chart-render, trade-replay, and trade-debrief consume this skill's output as input.Other plugins' skills for the same job