Overview
The "TRP Stop-Loss and Position Sizing" indicator is a powerful risk management tool designed to help traders calculate stop-loss levels and optimal position sizes based on market volatility. Using the True Range Percentage (TRP)—a 50-period EMA of the True Range expressed as a percentage of the closing price—this indicator provides dynamic stop-loss prices for long and short entries, position sizes in shares, and the capital required to execute trades. All plotted outputs are set to zero transparency (invisible) by default, allowing traders to focus on numerical values in the Data Window, with the option to adjust visibility as needed.
Purpose
Stop-Loss Calculation: Determines precise stop-loss levels for long and short positions based on current volatility.
Position Sizing: Scales trade size to a user-defined risk percentage, ensuring consistent risk management.
Capital Planning: Estimates the capital needed to enter a position, aiding in trade preparation.
This indicator is ideal for traders seeking a systematic approach to risk control across various markets and timeframes.
How It Works
TRP Calculation:
Computes the True Range (TR) as the greatest of:
High - Low.
|High - Previous Close|.
|Low - Previous Close|.
Converts TR to a percentage of the closing price: (TR / close) * 100.
Applies a 50-period EMA to smooth the percentage, yielding TRP (%).
Stop-Loss Distance:
Converts TRP to a price value: close * (TRP / 100).
This distance is subtracted from close for long stop-loss (sl_long) and added for short stop-loss (sl_short).
Position Sizing:
Calculates risk amount: capital * (rpt / 100).
Determines shares: risk_amount / sl_distance, ensuring the position matches the risk tolerance.
Capital Required:
Multiplies shares by the current price: shares * close, showing the dollar amount needed for the trade.
Inputs
Capital Size ($):
Default: 10,000
The total trading capital available. Minimum: 1.
Risk Per Trade (%):
Default: 1.0
The percentage of capital risked per trade. Step: 0.1, Minimum: 0.1.
Outputs
All outputs are plotted in a separate pane and are fully transparent (invisible) by default. Values can be viewed in the Data Window (Ctrl+D) or Labels:
SL Long:
Stop-loss price for long entries (red, transparency 100).
SL Short:
Stop-loss price for short entries (cyan, transparency 100).
TRP (%):
True Range Percentage as a line (purple, transparency 100).
Position Size (Shares):
Number of shares to trade (yellow, transparency 100).
Capital Required ($):
Dollar amount needed for the position (blue, transparency 100).
Usage
Add to Chart: Copy-paste into TradingView’s Pine Editor and click "Add to Chart."
View Values: Open the Data Window (Ctrl+D) or hover over bars to see SL levels, shares, and capital required.
Adjust Visibility:
Go to Settings > Style tab.
Reduce transparency (e.g., from 100 to 0) for any plot to make lines visible on the chart.
Customize: Adjust Capital Size and Risk Per Trade to fit your trading strategy.