OPEN-SOURCE SCRIPT
Precision Exit Planner

This indicator provides traders with a complete visual framework for planning trade exits before entering a position. Rather than generating buy or sell signals, this tool focuses on the critical post-entry phase: defining stop-loss placement, setting multiple take-profit targets, and calculating position size based on risk parameters.
What This Indicator Does
The Precision Exit Planner displays horizontal price levels representing your entry, stop-loss, and up to three take-profit targets. These levels are shown as colored lines extending to the right of the current price action, with accompanying price labels and optional colored zones that visually map your risk and reward areas. An information panel provides real-time calculations including risk-reward ratios and, when enabled, position sizing metrics.
How It Works
-Entry Price Determination
The entry price can be set through multiple methods. Manual mode allows you to input a specific price, useful for planning trades at anticipated levels before the market reaches them. Candle Open uses the current bar's opening price for real-time planning immediately after entry. Previous Bar modes (Close, High, Low) anchor to the prior bar's price points, which suits breakout strategies using the previous bar's high or pullback entries using the previous low.
-Stop-Loss Calculation
Three stop-loss methods are available. Percent mode places the stop at a fixed percentage distance from entry, providing consistent risk regardless of volatility. ATR mode uses the Average True Range indicator multiplied by a configurable factor, automatically adapting to current market volatility. Fixed Points mode uses an absolute price distance measured in the instrument's minimum tick units, suitable for futures or when you need precise tick-based stops.
-Take-Profit Calculation
Take-profit levels can be calculated using four methods. Percent mode mirrors the stop-loss percent approach. ATR mode uses separate ATR multipliers for each target, allowing volatility-adjusted profit targets. Fixed Points mode uses absolute distances like the stop-loss equivalent. Risk Multiple mode defines take-profits as multiples of your stop-loss distance, directly targeting specific risk-reward ratios (e.g., 2.0 creates a 2:1 reward-to-risk at that level).
-Position Sizing (Optional)
When enabled, the position sizing calculator determines optimal trade size based on your account balance and chosen risk percentage per trade. The formula divides your dollar risk (account balance multiplied by risk percent) by the risk per unit (stop-loss distance multiplied by contract value), yielding the position size that risks exactly your specified percentage.
-Partial Exit Allocation (Optional)
This feature calculates projected dollar profits when scaling out of a position at different take-profit levels. You define what percentage of your position to exit at each target (e.g., 33% at TP1, 33% at TP2, 34% at TP3), and the panel displays expected profit from each partial exit plus the total projected profit if all targets are reached.
-Break-Even Stop Level (Optional)
Displays a separate price level showing where to move your stop-loss after the first target is hit, typically to your entry price plus a small offset to cover commissions. This level appears as a dashed orange line when enabled.
-Pip/Point Display (Optional)
Converts all distance measurements from price units to pips or points using a configurable multiplier. Standard forex pairs use 10000, JPY pairs use 100, and stock indices typically use 1. This allows traders who think in pip terms to see familiar units.
Visual Representation
The indicator draws colored background zones between price levels. Green zones (with configurable opacity) appear between entry and take-profit levels, visually representing reward potential. The red zone between entry and stop-loss represents risk. The opacity gradient (default 85, 65, 55 for TP zones) creates visual emphasis on extended targets.
How To Use It
Trade Planning Workflow
1. Set your Trade Side (Long or Short) based on your directional bias
2. Input your Entry Price using manual mode for planned trades, or select an anchor mode for real-time entries
3. Configure Stop-Loss using your preferred method (percentage for simplicity, ATR for volatility adaptation, fixed points for precision)
4. Set Take-Profit targets using the same method consistency or Risk Multiple mode to target specific risk-reward ratios
5. Enable Position Sizing if you need to calculate lot/share size based on account risk parameters
6. Enable Partial Exits to plan scaling out of the trade
Alert Usage
The indicator includes alerts for when price touches or crosses any of your defined levels. Set alerts on TP1, TP2, TP3, Stop Loss, Entry Level, or Break-Even to receive notifications without watching the chart. The "Any Exit Level Hit" alert triggers on any TP or SL touch.
What Makes This Tool Original
Unlike simple TP/SL line drawers, this tool integrates multiple calculation methods (percent, ATR, fixed points, risk multiples) for both stops and targets within a unified interface. The position sizing calculator transforms abstract percentage risk into concrete position sizes. The partial exit allocation shows projected dollar outcomes for scaled exits, helping traders plan position management before entering. The Risk Multiple mode directly targets risk-reward ratios rather than requiring manual percentage calculations. All components work together: change your stop-loss distance and your position size, partial profit projections, and risk-multiple-based targets all recalculate automatically.
The Wait for Bar Close option ensures all calculations are based on confirmed prices, eliminating any repainting behavior when backtesting or analyzing historical setups.
Suitable Markets and Timeframes
This indicator works on any market including forex, stocks, futures, indices, and cryptocurrencies. Since it calculates relative distances and risk percentages, instrument type does not limit functionality. The pip multiplier setting accommodates different decimal conventions.
For day trading (5-minute to 1-hour charts), ATR mode with shorter ATR lengths (7-10) provides responsive stop-loss and target placement. For swing trading (4-hour to daily charts), standard ATR length (14) or percentage-based levels work effectively. For scalping (1-minute to 5-minute charts), fixed points mode or tight ATR multipliers (0.5-1.0) suit rapid-fire trade planning.
Settings Reference
General Settings
- Wait for Bar Close: Prevents repainting by updating only on confirmed bars
Entry Settings
- Entry Mode: Manual, Candle Open, Previous Bar Close/High/Low
- Manual Entry Price: Custom entry when using Manual mode
- Trade Side: Long or Short
Stop Loss Configuration
- Stop Loss Mode: Percent, ATR, or Fixed Points
- Stop Loss Percent: Distance as percentage of entry
- ATR Length: Lookback period for ATR calculation
- ATR Multiplier: Factor applied to ATR for stop distance
- Stop Loss Fixed Points: Absolute tick/pip distance
Take Profit Targets
- Take Profit Mode: Percent, ATR, Fixed Points, or Risk Multiple
- TP1/TP2/TP3 values for each mode
- Show TP2/TP3: Toggle visibility of extended targets
Position Sizing
- Enable Position Sizing Calculator: Toggle the feature
- Account Balance: Total account value
- Risk Per Trade %: Percentage willing to lose per trade
- Contract/Lot Value: Value per unit (100000 for forex standard lot, 1 for stocks)
Partial Exit Allocation
- Enable Partial Exit Allocation: Toggle the feature
- TP1/TP2/TP3 Exit %: Percentage of position to close at each level
Break-Even Stop
- Enable Break-Even Stop Level: Toggle the feature
- Break-Even Offset: Points beyond entry for the break-even stop
Pip/Point Display
- Enable Pip/Point Display: Toggle the feature
- Pip/Point Multiplier: Conversion factor for the instrument
Extended Labels
- Show RR Ratio on Labels: Display risk-reward ratio on price labels
- Show Pips on Labels: Display pip distance on labels
Visual Settings
- Show Information Panel: Toggle the data panel
- Panel Position: Choose from 9 chart positions (Top/Middle/Bottom + Left/Center/Right)
- Enable Background Zones: Toggle colored risk/reward zones
- Zone colors and opacity settings for visual customization
Disclaimer
This indicator is a trade planning and visualization tool. It does not predict future price movements or guarantee trade outcomes. All trading involves risk. Past performance of any trading methodology does not guarantee future results. Users should conduct their own analysis and risk assessment before entering any trade. Position sizes calculated by this tool are suggestions based on user inputs and should be verified against broker requirements and personal risk tolerance.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.