Trading Account
The Trading Account rule calculates comprehensive aggregated state data for trading activity on a specific broker account. It continuously monitors account-level metrics including equity, margin, risk exposure, and trading performance, providing real-time financial analytics and built-in risk management controls to protect your capital.
How It Works
The Trading Account rule serves as a comprehensive financial control and analytics system for a specific trading account. It continuously tracks equity, margin requirements, risk exposure, and trading performance across all trades placed on that account, updating in real time as price ticks, time-based events, or order updates occur.
The rule implements several important risk management features:
- Stop Out Margin Level: When the account’s margin level (calculated as Equity divided by Margin Used) falls below the stop out threshold, the rule automatically begins closing positions starting with the smallest ones first until the margin level is restored above the threshold.
- Minimum Trading Margin Level: When the margin level falls below this threshold, the rule prevents new positions from being opened, acting as a protective gate that ensures you always have adequate margin before entering new trades.
- Risk Amount (R): The rule tracks your defined risk amount, which can be set as either a fixed currency amount or a percentage of account equity. When the available risk amount reaches zero (meaning your losses have consumed your allocated risk), the rule triggers account closure to prevent losses beyond your defined risk parameters.
Beyond risk management, the rule provides extensive performance analytics. It tracks wins and losses by direction (buy and sell), calculates maximum drawdown (the peak-to-trough decline in account value), and monitors historical extremes for key metrics. It also tracks current equity (balance plus profit), free margin (funds available for new positions), and margin usage as percentages—giving you a complete picture of your account’s financial health at any moment.
Inputs
| Parameter | Description | Required | Default |
|---|---|---|---|
| Account | The broker account for which to calculate aggregated state data and risk metrics. | Yes | — |
| Stop Out Margin Level % | The margin level percentage threshold that triggers automatic position closing when the account’s margin level falls below this value. Positions are closed starting with the smallest first. | Yes | 50 |
| Min Trading Margin Level % | The margin level percentage threshold that prevents new positions from being opened when the account’s margin level falls below this value. | Yes | 100 |
| Risk Amount (R) Type | Determines whether the risk amount is specified as a fixed currency amount (Amount) or as a percentage of account equity (Percent). | Yes | Amount |
| Risk Amount (R) | The fixed amount of account equity to risk for this strategy. Only visible when Risk Amount Type is set to Amount. | When Type is Amount | — |
| Risk % | The percentage of current equity to risk for this strategy. Only visible when Risk Amount Type is set to Percent. | When Type is Percent | — |
| Starting Balance | The initial balance of the account, used as a reference point for calculating performance percentages and drawdowns. | No | — |
Outputs
| Output | Description |
|---|---|
| Profit | The aggregate profit or loss for all trades on the account, in the account’s currency. |
| Max Profit | The maximum profit achieved by the account throughout its trading history. |
| Max Loss | The maximum loss experienced by the account throughout its trading history. |
| Open Positions Profit | The aggregate profit or loss for only the currently open positions. |
| Closed Positions Profit | The aggregate profit or loss for only the closed positions. |
| Open Positions | The current number of open positions on the account. |
| Open Buy Positions | The current number of open buy (long) positions. |
| Closed Positions | The total number of closed positions. |
| Closed Buy Positions | The total number of closed buy positions. |
| Open Sell Positions | The current number of open sell (short) positions. |
| Closed Sell Positions | The total number of closed sell positions. |
| Max Open Buy Positions | The maximum number of simultaneous open buy positions reached at any point. |
| Max Open Sell Positions | The maximum number of simultaneous open sell positions reached at any point. |
| Open Orders | The current total number of open orders on the account. |
| Open Buy Limit Orders | The current number of open buy limit orders. |
| Open Sell Limit Orders | The current number of open sell limit orders. |
| Open Buy Stop Orders | The current number of open buy stop orders. |
| Open Sell Stop Orders | The current number of open sell stop orders. |
| Has Open Positions | A true/false value indicating whether any positions are currently open. |
| Margin | The required margin for all open positions, in the account’s currency. |
| Margin % | The required margin as a percentage of current equity. |
| Max Margin | The maximum margin required at any point throughout trading history. |
| Max Margin % | The maximum margin as a percentage of equity throughout trading history. |
| Draw Down | The current drawdown amount (peak profit minus current profit/loss). |
| Draw Down % | The current drawdown as a percentage of starting balance. |
| Max Draw Down | The maximum drawdown amount experienced (largest peak-to-trough decline). |
| Max Draw Down % | The maximum drawdown as a percentage of starting balance. |
| Equity | The current equity of the account (Balance plus Profit). |
| Balance | The starting balance of the account. |
| Free Risk Amount (R) | The remaining amount that can still be risked (Risk Amount plus Profit). |
| Free Risk % | The free risk amount as a percentage of the original Risk Amount. |
| Free Margin | The total available funds for new positions (Balance plus Profit minus Margin). |
| Margin Level | The margin level calculated as Free Margin divided by current Equity. |
| Min Free Margin | The lowest free margin experienced throughout the account’s execution. |
| Max Free Margin | The highest free margin experienced throughout the account’s execution. |
| Amount Won | The aggregate value of all closed winning trades. |
| Amount Won Buys | The aggregate value of all closed winning buy trades. |
| Amount Won Sells | The aggregate value of all closed winning sell trades. |
| Amount Lost | The aggregate value of all closed losing trades. |
| Amount Lost Buys | The aggregate value of all closed losing buy trades. |
| Amount Lost Sells | The aggregate value of all closed losing sell trades. |
| Won Positions | The total number of winning positions closed. |
| Won Buy Positions | The total number of winning buy positions closed. |
| Won Sell Positions | The total number of winning sell positions closed. |
| Lost Positions | The total number of losing positions closed. |
| Lost Buy Positions | The total number of losing buy positions closed. |
| Lost Sell Positions | The total number of losing sell positions closed. |
| Biggest Win | The largest single winning trade amount. |
| Biggest Buy Win | The largest single winning buy trade amount. |
| Biggest Sell Win | The largest single winning sell trade amount. |
| Biggest Loss | The largest single losing trade amount. |
| Biggest Buy Loss | The largest single losing buy trade amount. |
| Biggest Sell Loss | The largest single losing sell trade amount. |
| Average Win | The average amount of winning trades. |
| Average Buy Win | The average amount of winning buy trades. |
| Average Sell Win | The average amount of winning sell trades. |
| Average Loss | The average amount of losing trades. |
| Average Buy Loss | The average amount of losing buy trades. |
| Average Sell Loss | The average amount of losing sell trades. |
| Stop Out Margin Breached | True/false indicating whether the margin level has fallen below the stop out threshold. |
| Account Risk Limit Exceeded | True/false indicating whether risk exposure has exceeded the defined risk amount. |
| Min Trading Margin Breached | True/false indicating whether the margin level has fallen below the minimum trading margin threshold. |
Tips
Set the Stop Out Margin Level to a value recommended by your broker (commonly 50%) and the Min Trading Margin Level to at least 100% to ensure you always have adequate margin before entering new positions. Use the “Free Risk Amount” and “Free Risk %” outputs to feed into position sizing rules—this ensures your strategy automatically scales down position sizes as you approach your risk limit. The drawdown outputs are valuable for building circuit-breaker logic that pauses trading if drawdown exceeds a predefined threshold.
Was this helpful? Let us know