Lot Size CalculatorThis is a TradingView Pine Script indicator that calculates the correct lot size for a forex (or crypto) trade based on three key inputs: your account balance, how much you're willing to risk, and where your stop loss is. It displays the result in a clean on-chart dashboard table, and warns you if your risk exceeds 2%.
The core purpose is risk management — it tells you exactly how many lots to trade so you never risk more than your chosen percentage on any single trade.
How It Calculates
The maths behind it is straightforward and runs on two formulas:
Amount at Risk = Account Balance × (Risk % ÷ 100)
Lot Size = Amount at Risk ÷ (Stop Loss Size × Pip/Tick Value per Lot)
So for example, with a $10,000 account, 1% risk, a 25 pip stop loss, and a $10 pip value (e.g. EURUSD):
Amount at Risk = $10,000 × 0.01 = $100
Lot Size = $100 ÷ (25 × $10) = 0.40 lots
The lot size is then rounded to 2 decimal places.
The Warning System
If your risk percentage goes above 2%, two things happen:
The Risk % value in the table turns red
An on-chart warning label appears saying "HIGH RISK — You are risking over 2% of your account!"
This is a safety net to keep you disciplined with position sizing.
How to Use It
Step 1 — Account Settings
Enter your current account balance and the percentage of it you want to risk on the trade (e.g. 1%).
Step 2 — Stop Loss Settings
Choose whether your stop loss is measured in Pips or Ticks, then enter the size of your stop loss.
Step 3 — Pair Settings
Enter the pip or tick value per standard lot for the instrument you're trading:
EURUSD / GBPUSD = $10.00
USDJPY ≈ $9.30
Crypto / indices = check your broker's tick value
Step 4 — Read the Result
The Lot Size row at the bottom of the table gives you your answer. Enter that number into your broker's order panel.
Step 5 — Dashboard Customisation
Use the Dashboard settings to adjust the text size and position the table wherever suits your chart layout. Use the Colours group to fully customise all 10 colour elements to match your chart theme.
Important Notes
It is display only — it does not place trades or connect to a broker
Always double-check the pip value for your specific broker and instrument, as these can vary slightly
Pine Script® indicator













