OPEN-SOURCE SCRIPT
Updated Lot Size Calculator

Lot Size Calculator for Gold (XAU)
This indicator helps traders calculate the proper lot size for Gold (XAU) based on their entry, stop loss, and risk amount in USD.
You can set your entry and stop levels directly on the chart, and adjust your dollar risk from the settings panel.
The indicator measures the distance between entry and stop to calculate the position size that matches your selected risk.
A clean, customizable table displays key values such as Risk, Entry, Stop, Target, Lots, and Pips.
You can easily hide specific rows, change colors, and adjust layout options to fit your chart style.
Designed specifically for Gold traders, this tool provides a simple and visual way to manage risk directly on the chart.
This indicator helps traders calculate the proper lot size for Gold (XAU) based on their entry, stop loss, and risk amount in USD.
You can set your entry and stop levels directly on the chart, and adjust your dollar risk from the settings panel.
The indicator measures the distance between entry and stop to calculate the position size that matches your selected risk.
A clean, customizable table displays key values such as Risk, Entry, Stop, Target, Lots, and Pips.
You can easily hide specific rows, change colors, and adjust layout options to fit your chart style.
Designed specifically for Gold traders, this tool provides a simple and visual way to manage risk directly on the chart.
Release Notes
Lot Size Calculator for GoldThis indicator is designed exclusively for the XAUUSD symbol and will not activate on any other instrument.
It calculates the exact lot size needed so that a trade from Entry to Stop-Loss risks exactly the USD amount specified by the user.
Calculation formula
SL distance = |Entry price − Stop-Loss price|
Lot size = Risk in USD ÷ (SL distance × 100)
Features
- Works only on XAUUSD (automatically disabled on all other symbols)
- Entry and Stop-Loss prices are set by clicking directly on the chart
- Target price is calculated automatically based on user-defined Risk:Reward ratio (default 1:1)
- Visual elements: red box (risk zone), green box (reward zone), horizontal lines for Entry/Stop/Target
- Customizable table displaying: Risk ($), Entry, Stop, Target, Lots, Pips
- Full control over table position, colors, transparency and row visibility
How to use
- Apply the indicator to any XAUUSD chart
- When the indicator is first added, two pop-ups will appear — click on the chart to set Entry price first, then click again to set Stop-Loss price
- Set your desired Risk amount in USD in the settings (default $50)
- (Optional) Adjust the "R:R" input to change the Risk:Reward ratio — Target price will update automatically (default 1:1)
- Read the calculated Lot size from the table and use that exact volume in your broker
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.