Strategy Lock
Prevent multiple strategies from interfering with each other on the same account
Overview
Strategy Lock lets you tag positions with a strategy identity so that multiple automations running on the same account cannot accidentally interfere with each other. When you include a strategy_tag in your alert, CrossTrade locks that instrument on that account to the named strategy. Any subsequent order for the same instrument must carry the same tag — or it gets blocked.
This solves a common problem for traders running more than one automated strategy on a single NinjaTrader account. Without Strategy Lock, Strategy B's exit signal could close a position that Strategy A opened, or Strategy A could scale into a position that Strategy B is managing. With tagging, each strategy owns its positions and orders independently.
Strategy Lock is available in XT Add-On v1.12.0+. It is supported on all commands via webhooks, the and the CrossTrade API.
How It Works
Strategy Lock operates as a two-phase sidecar — it runs alongside the normal order validation pipeline without changing how orders themselves are placed. The system maintains a lightweight lookup of which strategy owns which instrument on which account.
Claiming a Lock
When an order with a strategy_tag arrives for an instrument that is currently flat with no working orders, the system claims the lock. From that point forward, the instrument on that account belongs to the named strategy.
A lock is claimed only after all other pre-flight checks pass (market position requirements, max positions, opposing position protection, etc.). This prevents "orphan tags," or locks that persist even though the order was ultimately rejected for a different reason.
Enforcing a Lock
Once a lock exists, every incoming order for that instrument is checked:
Matching tag — the order proceeds normally.
Different tag — the order is blocked with an error identifying which strategy currently owns the position.
No tag — the order is blocked. Untagged orders cannot interact with tagged positions.
Releasing a Lock
Locks are released automatically when the position closes (goes flat) and there are no remaining working orders for that instrument. You do not need to manually clear tags under normal conditions.
If a position goes flat but working orders still exist (e.g., a pending limit entry from the same strategy), the lock is preserved until those orders are filled or canceled. This prevents another strategy from claiming the instrument while a resting entry is still live.
CancelAllOrders and FlattenEverything are nuclear commands. They do not respect strategy tags and will act on all positions and orders regardless of ownership. Use them only when you intend to wipe everything.
Webhook Fields
To use Strategy Lock, add a strategy_tag field to your alert payload.
STRATEGY_TAG
No
A string identifier for your strategy (e.g., momentum, mean-revert, scalper-A). Case-insensitive.
The tag can be any string you choose. It is compared case-insensitively, so Momentum and momentum are treated as the same strategy.
Example Payloads
Opening a tagged position:
key=your-secret-key; command=PLACE; account=Sim101; instrument=ES 09-25; action=BUY; qty=1; order_type=MARKET; tif=DAY; strategy_tag=momentum;
A second strategy attempting to trade the same instrument (blocked):
key=your-secret-key; command=PLACE; account=Sim101; instrument=ES 09-25; action=SELL; qty=1; order_type=MARKET; tif=DAY; strategy_tag=mean-revert;
This order is rejected with the error: Trade blocked: ES 09-25 is managed by strategy 'momentum' with an open position. Request from 'mean-revert' rejected.
The owning strategy closing its position (allowed):
key=your-secret-key; command=PLACE; account=Sim101; instrument=ES 09-25; action=SELL; qty=1; order_type=MARKET; tif=DAY; strategy_tag=momentum;
Once the position is flat and no working orders remain, the lock is automatically released and any strategy can open a new position on ES.
Using Strategy Lock with Strategy Sync
Strategy Lock works alongside sync_strategy. When both features are present in the same payload, the strategy tag check runs first. If the tag check passes, the sync logic runs as normal. If the tag check fails, the order is rejected before sync evaluation begins.
key=your-secret-key; command=PLACE; account=Sim101; instrument=NQ1!; action={{strategy.order.action}}; qty={{strategy.order.contracts}}; order_type=MARKET; tif=DAY; strategy_tag=my-nq-strategy; sync_strategy=true; market_position={{strategy.market_position}}; prev_market_position={{strategy.prev_market_position}}; out_of_sync=flatten;
Using Strategy Lock with CancelAndBracket
CANCELANDBRACKET also supports strategy_tag. The tag check runs before the cancel and bracket placement. If the instrument is locked to a different strategy, the entire operation is blocked.
key=your-secret-key; command=CancelAndBracket; account=Sim101; instrument=ES 09-25; action=BUY; qty=2; take_profit=5620.00; stop_loss=5580.00; strategy_tag=momentum;
During the cancel window (the brief period between canceling existing orders and placing the new bracket), a transition guard protects the tag from being prematurely released. If a stop loss fills during this window and the position goes flat, the bracket placement is safely aborted — no naked entry is created, and the tag is cleaned up.
Self-Healing: Zombie Tag Cleanup
In rare edge cases, a crash, a manual intervention outside of CrossTrade, or a connection drop at exactly the wrong moment, a tag can become "stuck" on an instrument that is actually flat with no working orders. This is called a zombie tag.
The system automatically detects and removes zombie tags in two places:
On every incoming order — before evaluating the lock, the system checks whether the position is physically flat with no working orders. If so, the stale tag is removed and the order proceeds as if no lock existed.
Periodically — a background sweep checks all active tags and removes any that no longer correspond to a live position or working order.
You never need to worry about manually clearing zombie tags.
Important Behavior
What Strategy Lock Does NOT Do
It does not propagate tags through the Trade Copier. The copier operates at the account level, not the strategy level.
It does not protect against
CancelAllOrdersorFlattenEverything. These commands are intentionally nuclear and bypass all tag checks.It does not claim untagged positions. If a position was opened without a
strategy_tag, no strategy can retroactively claim it by sending a tagged order. The tagged order will be blocked because an unmanaged position already exists.
Working Orders Count
A lock is not just based on the open position; it also considers working (pending) orders. If Strategy A places a limit order on ES and it hasn't filled yet, the lock is held. Strategy B cannot place an order on ES even though the position is technically flat, because Strategy A has a resting order that represents strategic intent.
Tag Persistence
Strategy tags are persisted and survive add-on restarts. When the add-on reconnects, all active tags are restored automatically.
Interaction with Trade Copier
The Trade Copier does not propagate strategy tags from leader to follower — this is by design. The leader account might have multiple strategies contributing to a single net position, and there is no single tag that accurately represents that aggregate.
Instead, the copier has a strategy tag "mode" setting that controls how it behaves when it encounters a tagged position on a follower account:
override (default)
The copier removes the tag and proceeds. A prominent log entry is written and the removal is broadcast. Use this when the copier should take priority over everything else on the follower.
skip
The copier leaves tagged positions alone. Sync corrections are blocked, flatten operations exclude the tagged instrument, and order copies to that instrument are skipped. Use this when the follower runs independent strategies on some instruments while copying others.
Log Messages
[Strategy Lock] Sim101 ES 09-25 → locked to strategy 'momentum'
A tag was successfully claimed.
Trade blocked: ES 09-25 is managed by strategy 'momentum' with an open position.
An untagged or differently-tagged order was rejected.
Trade blocked: An unmanaged position already exists for ES 09-25. Cannot claim for strategy 'momentum'.
A tagged order tried to claim an instrument that already has an untagged position.
[Strategy Lock] Position closed: Sim101 ES 09-25 — releasing strategy tag 'momentum'.
The position went flat and the lock was released.
[Strategy Lock] Preserving tag for Sim101|ES 09-25: position is flat but working orders exist
Position is flat, but resting orders keep the lock alive.
[Strategy Lock] Removing orphaned tag for Sim101|ES 09-25. Account is flat with no working orders.
A zombie tag was detected and cleaned up.
Last updated