OPEN-SOURCE SCRIPT

Realtime Position Calculator

48
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.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.