OPEN-SOURCE SCRIPT

Lot Size Table

180
Lot Size Table Indicator – Pine Script (v5)
This TradingView script, “Lot Size Table,” creates a dynamic on-chart table that helps forex traders quickly calculate position sizes (lot sizes) for different capital and risk settings across various stop-loss (SL) pip scenarios.

🔧 Key Features:
📊 Real-time Forex Price Integration
Retrieves daily forex prices from OANDA for accurate lot size adjustments.

Instruments supported: USDJPY, USDCHF, AUDUSD, GBPUSD, NZDUSD, USDCAD, EURUSD.

🧠 Smart Lot Size Adjustments
Custom function adjustLotSize() adjusts lot sizes based on:

The currency of the instrument (e.g., JPY, GBP, AUD, etc.).

Special multiplier for symbols like US30 (e.g., ×8.5).

🧾 Flexible Capital & Risk Inputs
Supports 3 customizable capital groups, each with its own:

Capital amount

Risk percentage

📉 Multiple Stop-Loss (SL) Scenarios
Users input a comma-separated list of SL pip values (e.g., "20,25,30,...").

For each SL value, lot sizes are calculated for all 3 capital/risk combinations.

📋 Formatted On-Chart Table
Displays in a user-selected corner of the chart.

Customizable size, background color, and border.

Header row includes capital values and risk % (formatted to "k" if over 1,000).

Remaining rows show calculated lot sizes for each SL pip value.

📐 How It Works:
User Inputs: Capital, risk %, SL pip list, and table styling.

Calculation:

Lot size = (capital × risk%) / (SL pips × 10)

Adjusted based on instrument’s currency.

Display:

Table shows all SL pip scenarios and the corresponding adjusted lot sizes for each capital group.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.