OPEN-SOURCE SCRIPT
Position Size Calculator

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.
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的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。