OPEN-SOURCE SCRIPT
Realtime Position Calculator

Risk management is the single most important factor in trading success. This indicator automates the process of position sizing in real-time based on your account risk and a dynamic technical Stop Loss. It eliminates the need for manual calculations and helps you execute trades faster while adhering to strict risk management rules.
How it Works
The indicator visually places a Stop Loss line based on recent market structure (Highs/Lows) and instantly calculates the required position size (Contracts/Lots) to match your defined monetary risk.
1. Dynamic Stop Loss: It identifies the highest high (for Shorts) or lowest low (for Longs) over a user-defined lookback period.
2. Position Calculation: It calculates the distance between the current price and the Stop Loss level.
3. Formula: Contract Size = Risk Amount / (Distance * Point Value)
4. Actual vs. Target Risk: Because of the rounding, the script calculates and displays the Actual Risk (e.g., $95) alongside your Target Risk (e.g., $100), so you know exactly what is at stake.
Key Features
Real-time Calculation: Updates instantly as price moves.
Copy Trading Support: Includes an "Account Multiplier" setting. If you trade 10 accounts via a copy trader, set the multiplier to 10. The indicator will show the total contract size needed across all accounts.
Point Value Support: Works for Stocks/Crypto (Point Value = 1) and Futures (e.g., ES = 50, NQ = 20).
Customizable UI: Toggle specific data on/off in the label (e.g., hide price, show only contracts). Adjustable label offset to keep the chart clean.
Settings Guide
Trade Direction: Toggle between Long and Short setups. Add the indicator two times and set another for Longs and another for Shorts so you can see both direction at the same time.
Risk Amount: Your max risk in currency (e.g., $100).
Lookback: How many bars back to look for the SL pivot (e.g., 10 bars).
Point Value: Crucial for Futures. Use 1.0 for Crypto/Stocks. Use tick value/point value for futures (e.g., 50 for ES).
Account Multiplier: Multiply the position size for multiple accounts.
Label Offset: Move the information label to the right to avoid overlapping with price action.
Disclaimer
This tool is for informational and educational purposes only. Always verify calculations manually before executing trades. Past performance is not indicative of future results.
How it Works
The indicator visually places a Stop Loss line based on recent market structure (Highs/Lows) and instantly calculates the required position size (Contracts/Lots) to match your defined monetary risk.
1. Dynamic Stop Loss: It identifies the highest high (for Shorts) or lowest low (for Longs) over a user-defined lookback period.
2. Position Calculation: It calculates the distance between the current price and the Stop Loss level.
3. Formula: Contract Size = Risk Amount / (Distance * Point Value)
4. Actual vs. Target Risk: Because of the rounding, the script calculates and displays the Actual Risk (e.g., $95) alongside your Target Risk (e.g., $100), so you know exactly what is at stake.
Key Features
Real-time Calculation: Updates instantly as price moves.
Copy Trading Support: Includes an "Account Multiplier" setting. If you trade 10 accounts via a copy trader, set the multiplier to 10. The indicator will show the total contract size needed across all accounts.
Point Value Support: Works for Stocks/Crypto (Point Value = 1) and Futures (e.g., ES = 50, NQ = 20).
Customizable UI: Toggle specific data on/off in the label (e.g., hide price, show only contracts). Adjustable label offset to keep the chart clean.
Settings Guide
Trade Direction: Toggle between Long and Short setups. Add the indicator two times and set another for Longs and another for Shorts so you can see both direction at the same time.
Risk Amount: Your max risk in currency (e.g., $100).
Lookback: How many bars back to look for the SL pivot (e.g., 10 bars).
Point Value: Crucial for Futures. Use 1.0 for Crypto/Stocks. Use tick value/point value for futures (e.g., 50 for ES).
Account Multiplier: Multiply the position size for multiple accounts.
Label Offset: Move the information label to the right to avoid overlapping with price action.
Disclaimer
This tool is for informational and educational purposes only. Always verify calculations manually before executing trades. Past performance is not indicative of future results.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
- Viltsu / x.com/ViltsuFIN
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
- Viltsu / x.com/ViltsuFIN
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.