Auto-Flatten and Account Locking: What Happens When Limits Are Hit
The two-stage protection system that ensures your positions are closed safely before locking the account.
7 min read
When a risk limit is breached — whether it is a daily loss limit, weekly loss limit, profit target, or trailing drawdown — MimikTrader does not simply reject future trades. It actively intervenes by closing all open positions and locking the account to prevent further trading. This article explains the exact sequence of events, the intermediate states your account passes through, and how to recover after a lock.
The Two-Stage Protection Sequence
When the real-time risk monitor detects a breach, the account goes through two distinct stages. This two-stage approach exists because closing positions requires broker communication that can take a few seconds, and the account must be protected during that window.
Stage 1: LIQUIDATE_ONLY
The moment a breach is detected, the account's risk status transitions to LIQUIDATE_ONLY. In this state:
- All new opening trades are blocked. If the leader enters a new position, the follower will reject the trade with the reason: "Account is in LIQUIDATE_ONLY mode — only closing trades allowed."
- Closing and reducing trades are still permitted. If the leader closes a position, the follower is allowed to close as well. This is critical — you never want a follower stuck with an open position it cannot close.
- MimikTrader simultaneously sends flatten orders to the broker to close all open positions via market orders.
Stage 2: LOCKED
Once the account's position reaches zero (flat), MimikTrader automatically transitions the status from LIQUIDATE_ONLY to LOCKED. In the fully locked state:
- All trades are blocked — both opening and closing.
- The account is effectively frozen. No leader activity will produce any follower orders on this account.
- The lock persists until it is either manually released by you or automatically cleared by the appropriate reset timer (daily at 5 PM CT for daily breaches, Sunday at 5 PM CT for weekly breaches).
What Triggers Auto-Flatten
The real-time risk monitor runs on every price tick for instruments with open positions. It can trigger auto-flatten for any of these conditions:
- Daily loss limit: The sum of realized daily P&L plus unrealized P&L drops to or below the negative of the configured daily loss limit.
- Daily profit target: The sum of realized daily P&L plus unrealized P&L reaches or exceeds the configured daily profit target.
- Trailing drawdown: The equity (balance plus total daily P&L) drops below the high-water mark by the configured drawdown distance.
- Weekly loss limit: The accumulated weekly P&L plus current unrealized P&L drops to or below the negative of the configured weekly loss limit.
- Weekly profit target: The accumulated weekly P&L plus current unrealized P&L reaches or exceeds the configured weekly profit target.
The Flatten Process in Detail
When a breach is detected, here is the exact sequence of operations:
- 1
Flatten request sent to broker
MimikTrader sends market orders to close all open positions on the affected account. For Tradovate accounts, this uses the liquidatePosition API endpoint which closes the entire position in a single call. - 2
Risk status set to LIQUIDATE_ONLY
The risk profile is updated to LIQUIDATE_ONLY status. This happens concurrently with the flatten request so the account is immediately protected from new trades even if the flatten takes a moment to execute. - 3
Follower replication disabled
A disable reason is written to the follower record in the copy group, providing visibility in the dashboard as to why the follower stopped receiving trades. - 4
Account state updated
The account's position is set to zero, the symbol is cleared, and the unrealized P&L is zeroed out. The realized daily P&L is updated to include the P&L from the closed position. - 5
Activity log entry created
A warning-level activity log entry is created recording the breach reason, the P&L at the time of breach, and the flatten action taken. - 6
Transition to LOCKED when flat
If the flatten was successful and the position is now zero, the status automatically transitions from LIQUIDATE_ONLY to LOCKED.
How to Unlock an Account
Locked accounts can be unlocked in two ways, depending on what caused the lock:
Automatic Unlock
- Daily lock: Automatically unlocked at the daily reset (5 PM CT every trading day). The next morning, the account starts fresh with zero daily P&L and a status of OK.
- Weekly lock: Automatically unlocked at the weekly reset (Sunday 5 PM CT). The new trading week starts with zero weekly P&L and a status of OK.
Manual Unlock
You can manually unlock any account from the Risk Management page by toggling the lock status. Use this when:
- You want to resume trading after reviewing what caused the breach.
- The lock was triggered by a profit target and you want to continue trading for the day.
- You have adjusted your risk parameters and want to restart with new limits.
Lock Reasons and Their Persistence
Each lock carries a reason that determines how long it persists and which reset clears it:
risk_breach_daily— Cleared by the daily reset at 5 PM CT. Triggered by daily loss limit, daily profit target, or trailing drawdown breaches.risk_breach_weekly— Cleared by the weekly reset on Sunday at 5 PM CT. Triggered by weekly loss limit or weekly profit target breaches. Not affected by daily resets.- Manual lock — Only cleared by manual action. Not affected by any automatic reset timer.
What Happens to Open Positions
When auto-flatten triggers, every open position on the account is closed with a market order. After the flatten:
- The account's position is set to zero across all instruments.
- Unrealized P&L becomes zero (since there are no open positions).
- Realized daily P&L is updated to include the P&L from the now-closed positions.
- All pending orders (working limit orders, stop orders) are canceled at the broker level.