OPEN-SOURCE SCRIPT
Position calculator (without Forex)

That's an excellent idea. Here is a complete description of the simplified Pine Script v6 position size calculator, written in English.
📐 Pine Script V6 Position Size Calculator: Full Description
This Pine Script v6 indicator is a simplified, universal position size calculator designed for traders to quickly determine the exact quantity of an asset (shares, crypto units, etc.) they should trade to maintain a specific risk tolerance. It focuses solely on the most common and accessible calculation method: determining the number of units/contracts.
1. 🎯 Purpose
The primary goal of the script is to answer the question: "Given my total account capital and a defined stop-loss price, how many units of this asset can I buy/sell while only risking a specified percentage of my capital?"
It uses the classic position sizing formula:
Position Size (Units)=Risk Per UnitAccount Risk Amount
2. ⚙️ Indicator Settings (Inputs)
The script provides the user with five key adjustable parameters, all located in the indicator's settings panel:
Parameter Type Default Value Description
Capital total ($) float 10000.0 Your total trading account balance. This is the basis for calculating the risk amount.
Risque par trade (%) float 1.0 The maximum percentage of your capital you are willing to lose on this specific trade.
Prix d'Entree float 150.0 The target entry price for the trade. Since the "use current price" option was removed, this manual price is always used.
Prix Stop Loss float 145.0 The protective stop-loss price where you will exit the trade.
📐 Pine Script V6 Position Size Calculator: Full Description
This Pine Script v6 indicator is a simplified, universal position size calculator designed for traders to quickly determine the exact quantity of an asset (shares, crypto units, etc.) they should trade to maintain a specific risk tolerance. It focuses solely on the most common and accessible calculation method: determining the number of units/contracts.
1. 🎯 Purpose
The primary goal of the script is to answer the question: "Given my total account capital and a defined stop-loss price, how many units of this asset can I buy/sell while only risking a specified percentage of my capital?"
It uses the classic position sizing formula:
Position Size (Units)=Risk Per UnitAccount Risk Amount
2. ⚙️ Indicator Settings (Inputs)
The script provides the user with five key adjustable parameters, all located in the indicator's settings panel:
Parameter Type Default Value Description
Capital total ($) float 10000.0 Your total trading account balance. This is the basis for calculating the risk amount.
Risque par trade (%) float 1.0 The maximum percentage of your capital you are willing to lose on this specific trade.
Prix d'Entree float 150.0 The target entry price for the trade. Since the "use current price" option was removed, this manual price is always used.
Prix Stop Loss float 145.0 The protective stop-loss price where you will exit the trade.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.