OPEN-SOURCE SCRIPT

Risk Management & Position size calculator (FinPip)

1 623
# 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).*

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.