Guides, manuals and platform references.
A trade disappears before the planned stop, yet the exit rule has not fired. Before rewriting the strategy, check whether the trade report labels the exit Margin Call. That points to the simulation's funding constraint rather than your ordinary exit condition.
This distinction matters in TradingView automation. Keep three records separate: what the strategy simulated, what an alert requested, and what the destination account actually did. For an AlgoWay workflow, use the backtest and execution-metrics guide to structure that comparison. A chart's margin setting is not evidence of the connected account's margin policy.
Pine defines separate margin percentages for long and short positions. The current Pine manual describes the corresponding Properties controls as Long leverage and Short leverage; the help article uses the older margin-percentage labels. Convert the units before comparing settings. A 25% requirement means funding one quarter of position value, allowing up to four times the available capital in this simplified model. It does not mean a 25% stop loss, and it does not automatically choose that maximum position size. TradingView describes these settings and the liquidation condition in its leverage simulation guide.
The key comparison is current equity ≤ required margin. Equity includes open profit or loss. Required margin depends on current position value and the selected percentage. Both sides can move while the trade remains open.
Here is an invented long-position example, not a backtest result. Assume $2,000 starting equity, no earlier profit, no fees, one dollar of value per price point per unit, and 60 units bought at $100. Set the long margin requirement to 25%.
| Current price | Open P/L | Equity | Required margin | Comparison |
|---|---|---|---|---|
| $100 | $0 | $2,000 | $1,500 | Equity exceeds requirement |
| $90 | −$600 | $1,400 | $1,350 | $50 cushion remains |
| $88 | −$720 | $1,280 | $1,320 | $40 shortfall |
For this example, equity at price P is 2000 + 60 × (P − 100). Required margin is 60 × P × 0.25. Equating them gives P = $88.888… before considering a valid price increment. That is an arithmetic boundary, not a promise that the emulator will execute exactly there.
Notice the trap: required margin fell from $1,500 to $1,320, but equity fell faster. A smaller margin requirement does not imply that the account became safer. The position still owns the same 60 units until some action reduces it.
TradingView's broker emulator uses four times its calculated amount needed to cover the shortage, subject to the position and quantity rules. The purpose is to reduce repeated margin-call events. Do not read the resulting exit quantity as a take-profit percentage chosen by your script. Setting margin to zero disables the constraint rather than repairing the strategy; even 100% margin does not remove short-position liquidation risk.
The Pine strategies documentation details the calculation and the public strategy.margin_liquidation_price variable. Treat that variable as information about the emulator. It is not a query to your broker.
If the uncertainty is which prices the emulator saw inside a candle, consult the Bar Magnifier explanation. Intrabar fill detail and margin adequacy answer different questions.
Before running the workflow on an account, document the destination's actual margin requirements and what happens if its position diverges from the strategy's position. A simulated forced exit is a reason to reconcile those records. It is not proof that the broker received an exit instruction.