OPEN-SOURCE SCRIPT

Position Size Calculator

513
POSITION SIZE CALCULATOR

Calculating the exact number of shares to buy before entering a trade can be slow and distracting. This on-chart indicator does all the position sizing math for you in real time.

Simply enter your total account balance, choose your preferred allocation percentages, and the script displays an on-screen table showing the exact amount to invest and the number of whole shares to buy.


WHAT IT DOES

- Automatic Share Sizing: Calculates whole shares to buy based on your capital and allocation percentages.
- 3 Allocation Tiers: Configure 3 custom sizing options (e.g. 10%, 20%, 30%) to suit different trade setups.
- Live or Manual Price:
- By default, it takes the confirmed close price of your chosen timeframe (e.g. 5-min, Daily).
- Or toggle "Manual Entry Price" to calculate sizes for planned limit orders.
- Safe Math: Always rounds down to complete shares (math.floor) so you never exceed your intended risk.
- Clean & Flexible Display: Fully customizable table position, color themes, and an option to hide the table outside regular market hours.


HOW TO USE IT

1. Add the indicator to your chart.
2. Open Settings (the gear icon on the indicator label):
- Account: Enter your total trading capital.
- Allocation Tiers: Set your allocation percentages for Tier 1, 2, and 3.
- Price Settings: Keep automatic close price detection, or check "Use Manual Entry Price" and type your limit price.
3. Check the on-chart table:
- Find your desired tier column.
- Read the green highlighted number in the "Shares" row and place your order.


CUSTOMIZATION OPTIONS

- Show/Hide Investment Row: Display only the share count or include the cash value.
- Hide When Market Closed: Automatically hides the table when the market is inactive to keep your charts clean.
- Table Position: Move the table to any corner or side of your screen (Top-Right, Top-Left, Bottom-Right, etc.).
- Colors: Adjust background, border, text, and highlight colors to fit dark or light charts.


DISCLAIMER

This script is a position sizing calculation tool and does not provide financial advice, buy/sell signals, or trade recommendations. Always manage your risk according to your personal trading plan.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。