Risk management for TradingView strategies: exposure and review rules
Risk management in trading specifies how much a position can lose under planned exits, how much exposure the account can carry, and when new entries must stop. For a TradingView strategy, turn those decisions into explicit inputs and review fields. A stop order and a daily loss threshold are instructions, not guaranteed loss ceilings: gaps, execution delays and costs can push the realized loss beyond either.
Where Pineify fits
Give Pine Script AI Coding Agent the explicit quantity formula, stop units, session boundary and pause rules to produce editable strategy code. Compile the source in TradingView and recompute its size and exit examples before interpreting a test. Record the original planned risk and actual result in Trading Journal, with exposure and breach details in notes. This workflow supports code review and recordkeeping; it does not replace broker margin rules, monitor every account position or automatically submit trades.
A checklist with measurable limits
The following is an illustrative policy for a USD 50,000 account holding ordinary long shares. Its percentages are assumptions for testing, not recommended or optimal settings. Freeze the policy version before testing. Apply every check to the proposed portfolio, including pending entries that could fill together. Recheck after fills, price changes and stop changes; a passed entry check can later become a breach.
| Control | Test at entry | Action when the test fails |
|---|---|---|
| Single-trade budget | Planned loss including cost allowance must be at most 0.5% of current equity ($250 initially). | Round quantity down or reject the entry. A wider stop requires a new size calculation. |
| Gross exposure | Sum absolute position market values, plus candidate orders, at no more than 100% of current equity ($50,000 initially). | Reduce quantity or reject. Also check cash, buying power and broker margin requirements separately. |
| Total open risk | Sum nonnegative losses from current marks to each stop, plus remaining costs, at no more than 1% of current equity ($500 initially). | Do not offset one position with another expected winner. Block additions and review existing exposure. |
| Correlated-position bucket | Apply a separate 0.75% equity risk budget ($375 initially) to holdings exposed to the same sector, underlying or event. | Resize or reject the candidate even when the account-wide risk check passes. |
| Daily loss trigger | Cash-flow-adjusted equity loss from session start, including open P&L and costs, must remain below 1.5% of session-start equity ($750). | At or above the trigger, cancel pending entries, request closure of open positions and block new entries for the session. |
| Operational stop | Prices, quantity, stop units and order status must reconcile with the intended rules. | Pause on stale data, a rejected exit, duplicate orders or a position mismatch. Confirm actual broker status before recovery. |
Size the trade, then check exposure
For this share example, quantity = floor(trade budget / (absolute entry-to-stop distance + round-trip cost allowance per share)). With $250 available, entry at $100, stop at $98 and a $0.10 per-share allowance, floor(250 / 2.10) = 119 shares. Planned loss is $249.90, while position value is $11,900. Tightening the stop can increase the calculated quantity and gross exposure, so passing the risk calculation does not establish that the position is affordable.
- Use positive equity and a positive stop distance. A long protective stop belongs below entry; a short protective stop belongs above entry. Reject missing or nonfinite inputs.
- Round down to the permitted quantity increment. If the result is below the minimum tradable size, skip the trade. Do not round up to use the budget.
- For linear contracts, convert price distance to cash with the contract point value and account-currency conversion. Check the exchange specification; share units do not transfer directly to futures or FX lots.
- An allowance estimates costs; it cannot cap slippage. Fixed order fees require their own treatment rather than pretending every fee is proportional to quantity.
- This linear calculation does not model option Greeks, inverse contracts or changing currency rates. Use instrument-specific valuation and broker rules for those exposures.
Three trades can pass alone and fail together
Assume all three proposed positions enter together at the listed prices, with a $0.10 round-trip cost allowance per share. A and B are hypothetical companies assigned to the same sector bucket; C has a different recorded risk driver. These are invented prices for arithmetic, not market observations or a claim of measured correlation. FINRA describes how sector holdings and overlapping funds can concentrate exposure even when the ticker names differ.
| Position | Quantity / entry / stop | Planned loss | Gross exposure |
|---|---|---|---|
| A: same-sector bucket | 100 shares / $100 / $98 | 100 × ($2 + $0.10) = $210 | $10,000 |
| B: same-sector bucket | 100 shares / $80 / $78 | 100 × ($2 + $0.10) = $210 | $8,000 |
| C: separate bucket | 50 shares / $120 / $118 | 50 × ($2 + $0.10) = $105 | $6,000 |
| All proposals | 250 shares across three instruments | $525 (1.05% of equity) | $24,000 (48% of equity) |
- Each trade passes the $250 single-trade budget, and $24,000 passes the gross exposure cap. The portfolio still fails: $525 exceeds $500, and A plus B risk $420 against their $375 bucket cap.
- With A and C unchanged, B can use at most min($250, $500 - $210 - $105, $375 - $210) = $165 of planned risk. Floor($165 / $2.10) gives 78 shares.
- At 78 B shares, bucket risk is $373.80, total planned risk is $478.80 (0.9576%), and gross exposure is $22,240 (44.48%). All entry checks pass under these assumptions.
- Record sector, underlying, currency and event exposures, including ETF overlap and positions outside this strategy. Historical correlation estimates depend on the return interval and sample; low past correlation does not remove the need for a common-shock test.
- Keep gross exposure and net direction separate. A long and a short in different instruments may offset net dollar value while leaving basis, liquidity and event risk.
Recheck simultaneous stops and a gap scenario
Use the resized portfolio: A has 100 shares, B has 78 and C has 50. First assume every stop fills at its trigger price. Then replace those fills with hypothetical gap exits at $95, $74 and $116. Keep the same $0.10 allowance so the effect of the gap is visible. FINRA explains that a triggered stop becomes a market order and can execute away from its trigger; a stop-limit order instead risks remaining unfilled.
| Scenario | A / B / C loss | Account loss | Review result |
|---|---|---|---|
| All stops fill as planned | $210 / $163.80 / $105 | $478.80, or 0.9576% | Below the $750 daily trigger if there are no earlier session losses. |
| All positions gap through stops | $510 / $475.80 / $205 | $1,190.80, or 2.3816% | Exceeds the daily trigger by $440.80 despite passing every entry budget. |
- Gap loss for B is 78 × ($80 - $74 + $0.10) = $475.80. The portfolio gap loss is about 2.49 times its planned stop loss.
- A daily trigger requests action after the loss is observed. It cannot recover a gap loss or guarantee a fill at the threshold.
- Before accepting the setup, compare the common-shock loss with a separately documented stress tolerance. Reduce size, avoid the event or reject the setup if that loss is unacceptable. The entry checklist alone does not settle this decision.
- Test larger gaps, higher costs and unavailable liquidity separately. The selected scenario is not a worst-case bound, a probability estimate or a historical backtest.
Specify the daily reset and restart conditions
Define one session boundary and timezone for the account. In this example, daily loss is max(0, session-start equity + net cash inflows - current equity), where current equity includes open P&L and costs. Deposits must not disguise a loss and withdrawals must not create one. The reference stays fixed through the session; profits do not ratchet it upward. This is a chosen start-of-session policy, so check any platform risk function against it before treating the function as equivalent.
- With no cash flows, $50,000 session-start equity and $49,250 current equity reach the $750 trigger exactly. A $400 realized loss plus $350 open loss also reaches it; waiting for positions to close would miss the trigger.
- After $400 of realized losses, the remaining distance to the trigger is $350. Recheck current open risk and any candidate against that room before adding exposure; gap losses can still exceed it.
- Log when the trigger was detected, which pending orders were cancelled, requested exits and actual fills. A failed cancellation or exit requires reconciliation rather than an assumed flat account.
- Keep the session lock active even if equity later recovers. Restart no earlier than the next defined session, after orders and positions reconcile and the cause of the breach has been reviewed.
- Pause separately for a rule violation or invalid data, even when P&L is positive. Record the correction and the new rule version before another test.
Translate the checklist into TradingView test inputs
TradingView strategy tests simulate orders for the chart symbol; separate chart strategies do not share a broker-account risk budget. Maintain the cross-position exposure ledger outside those individual tests. TradingView documents gap fills at the next bar open when price crosses an order level between bars. Its simulated intraday risk controls also have session and timeframe behavior that must match the policy you intend to test.
- Record symbol, timeframe, session, account currency, initial capital, quantity increment, point value and margin assumptions with each test.
- Check quantity units and the difference between a stop price and a distance in ticks. Use the entry and stop levels to reproduce the expected cash loss independently.
- Include commission and slippage assumptions. Compare ordinary fills with the separate gap scenarios above, and inspect trades around session boundaries.
- Test equality at each threshold, zero allowable quantity, multiple entries on one signal and a stop change after entry. Reject additions that would exceed any applicable budget.
- For an ATR stop, state the ATR length, multiplier and whether the value freezes at entry. Recalculate size when distance changes; no ATR multiplier guarantees protection from a stop sweep.
Compare planned risk with actual outcomes in the journal
Pineify Trading Journal has fields for entry, quantity, risk amount and stop-loss price, together with closing records and notes. Save the original planned risk before the result is known. Use notes for the policy version, session boundary, sector bucket and stress assumptions rather than assuming the journal enforces these portfolio limits.
| Review field | Example value |
|---|---|
| Plan | 78 shares at $80; stop $78; cost allowance $0.10 per share; planned risk $163.80. |
| Context in notes | Same-sector bucket with A; combined planned risk $373.80; policy and session identifiers. |
| Actual gap scenario | Exit $74; loss including assumed costs $475.80; excess over planned loss $312. |
| Risk multiple | Loss / original planned risk = $475.80 / $163.80 = 2.90; signed net result is -2.90R under this stated denominator. |
| Review decision | Classify gap execution separately from a sizing or rule error; record whether the next setup needs a smaller stress budget. |
This page is educational and does not provide investment advice. All prices, portfolio limits and stress scenarios shown here are hypothetical. Stops and risk triggers cannot guarantee a maximum loss. Trading can lose capital, and simulated results do not guarantee future outcomes.