OPEN-SOURCE SCRIPT

Position Size Calculator

232
Position Size Calculator
Computes quantity, position value, and risk-reward directly on the chart, checked against multiple stop-loss methods simultaneously. No manual calculation, no spreadsheet.

How it works
Enter account size and risk per trade. For each stop-loss method enabled, the table displays shares to buy or sell, capital required and percentage of account, recalculated on every tick.

Up to four stop definitions can be compared side by side:
1) Current Day Low/High: calculated from the current session
2) Previous Day Low/High: calculated from the prior session
3) Fixed Price: a manually set stop
4) Fixed %: a stop set as a distance from entry

Comparing columns shows how tightening or widening a stop changes position size for the same risk amount.

Features
1) Live table, recalculates every tick
2) Risk mode: percent of account or fixed currency amount
3) Long and short supported; stop logic adjusts automatically by direction
4) Optional target price adds R:R per stop column
5) Fixed Price and Fixed % toggle independently
6) Quantities floored to whole shares
7) Table position, text size, colors and borders are configurable

Setup
1) Enter account value, select risk mode (percent or fixed amount), and set the risk value.
2) Select Long or Short. Optionally enable a target price to compute R:R.
3) Enable Fixed Stop Price and/or Fixed Stop % as needed. Current Day and Previous Day stops calculate automatically.
4) Read the table: each active column shows stop price, quantity, position size, percent of account, and R:R (if a target is set).

An info banner above the table shows live entry price, direction, and target for reference.

Notes
- Entry price is always the live price. This is a real-time sizing tool, not a backtesting tool.
- Current Day and Previous Day stops require the chart timeframe to be Daily or lower. A warning appears in the banner if the timeframe is coarser.
- Quantity shows "n/a" when a stop is on the wrong side of entry for the selected direction, or when risk-per-share cannot be computed.

Disclaimer
This tool performs position-sizing calculations only. It does not predict price movement, generate trade signals, or constitute financial advice. Perform independent due diligence before entering any trade.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน