OPEN-SOURCE SCRIPT
Risk Management & Position size calculator (FinPip)

# Risk Management & Position size calculator (FinPip)
**Size your trades by risk.** Set your capital, risk %, entry and stop-loss — the indicator gives you position size in units, a take-profit level from your reward:risk ratio, and a clear summary on the chart.
Works on any symbol (stocks, forex, crypto, futures). Pine Script v6 · Mozilla Public License 2.0
---
## How to add to your chart
1. In TradingView, open **Indicators** (or search **“Risk Management”** / **“Finpip Risk Manager”**).
2. Select **Risk Management & Position size calculator (FinPip)** and add it to the chart.
3. Open **Settings** (gear on the indicator label) to set your capital, risk %, entry price, and stop-loss price.
---
## What you get
- **Entry, Stop-Loss & Take-Profit** — Drawn as horizontal lines on the chart (direction is Long if Entry > SL, Short if Entry < SL).
- **Position size** — Number of units (shares, lots, contracts) so that if price hits your SL, you lose only your chosen risk amount.
- **Info panel** — Capital, Risk %, Risk $, Reward $, R:R, Size (units), Risk/Unit, Entry/SL/TP prices, and direction. You can move the panel to any corner and change text size.
---
## Settings (inputs)
**Risk & Capital**
- **Total Account Capital ($)** — Capital used for risk (default 10000).
- **Risk per Trade (%)** — % of capital to risk on this trade (default 2.5%).
**Trade Levels**
- **Entry Price** — Your planned or actual entry.
- **Stop-Loss Price** — Exit price if the trade goes against you.
**Profit Target**
- **Reward:Risk Ratio** — Target as multiple of risk (e.g. 4 = 4R). TP is placed at Entry ± (SL distance × R:R).
**Display**
- **Show Info Panel** — On/off for the metrics table.
- **Round to Whole Shares/Units** — On for stocks/shares (whole numbers); off for forex/fractional.
- **Panel Position** — Top Left, Top Right, Bottom Left, Bottom Right.
- **Text Size** — Tiny / Small / Normal / Large.
- **Show Level Labels** — Price labels for Entry, SL, TP on the right.
**Colors** — Customize Entry, SL, TP lines and panel colors.
---
## How it’s calculated
- **Risk $** = Capital × (Risk % ÷ 100)
- **Risk per unit** = |Entry − Stop-Loss|
- **Position size** = Risk $ ÷ Risk per unit (optionally rounded down to whole units)
- **Take-profit** = Entry + (Risk per unit × R:R) for Long, or Entry − (…) for Short
- **Reward $** = Risk $ × R:R
---
## If something looks wrong
- **“Invalid setup — Entry and SL must be different prices”** — Your Entry and Stop-Loss are the same; change one of them.
- **“0 units (rounds to 0)”** — Risk $ is too small for the distance to SL with whole units. Increase capital or risk %, or turn off **Round to Whole Shares/Units** to see fractional size.
---
*Published on TradingView. Open source (MPL 2.0).*
**Size your trades by risk.** Set your capital, risk %, entry and stop-loss — the indicator gives you position size in units, a take-profit level from your reward:risk ratio, and a clear summary on the chart.
Works on any symbol (stocks, forex, crypto, futures). Pine Script v6 · Mozilla Public License 2.0
---
## How to add to your chart
1. In TradingView, open **Indicators** (or search **“Risk Management”** / **“Finpip Risk Manager”**).
2. Select **Risk Management & Position size calculator (FinPip)** and add it to the chart.
3. Open **Settings** (gear on the indicator label) to set your capital, risk %, entry price, and stop-loss price.
---
## What you get
- **Entry, Stop-Loss & Take-Profit** — Drawn as horizontal lines on the chart (direction is Long if Entry > SL, Short if Entry < SL).
- **Position size** — Number of units (shares, lots, contracts) so that if price hits your SL, you lose only your chosen risk amount.
- **Info panel** — Capital, Risk %, Risk $, Reward $, R:R, Size (units), Risk/Unit, Entry/SL/TP prices, and direction. You can move the panel to any corner and change text size.
---
## Settings (inputs)
**Risk & Capital**
- **Total Account Capital ($)** — Capital used for risk (default 10000).
- **Risk per Trade (%)** — % of capital to risk on this trade (default 2.5%).
**Trade Levels**
- **Entry Price** — Your planned or actual entry.
- **Stop-Loss Price** — Exit price if the trade goes against you.
**Profit Target**
- **Reward:Risk Ratio** — Target as multiple of risk (e.g. 4 = 4R). TP is placed at Entry ± (SL distance × R:R).
**Display**
- **Show Info Panel** — On/off for the metrics table.
- **Round to Whole Shares/Units** — On for stocks/shares (whole numbers); off for forex/fractional.
- **Panel Position** — Top Left, Top Right, Bottom Left, Bottom Right.
- **Text Size** — Tiny / Small / Normal / Large.
- **Show Level Labels** — Price labels for Entry, SL, TP on the right.
**Colors** — Customize Entry, SL, TP lines and panel colors.
---
## How it’s calculated
- **Risk $** = Capital × (Risk % ÷ 100)
- **Risk per unit** = |Entry − Stop-Loss|
- **Position size** = Risk $ ÷ Risk per unit (optionally rounded down to whole units)
- **Take-profit** = Entry + (Risk per unit × R:R) for Long, or Entry − (…) for Short
- **Reward $** = Risk $ × R:R
---
## If something looks wrong
- **“Invalid setup — Entry and SL must be different prices”** — Your Entry and Stop-Loss are the same; change one of them.
- **“0 units (rounds to 0)”** — Risk $ is too small for the distance to SL with whole units. Increase capital or risk %, or turn off **Round to Whole Shares/Units** to see fractional size.
---
*Published on TradingView. Open source (MPL 2.0).*
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.