OPEN-SOURCE SCRIPT
Position Sizer (Share Qty)

- This indicator enables fast & accurate position sizing for traders using (user defined) fixed dollar risk, eliminating the need for manual calculations and supporting disciplined risk management directly on the chart
- Calculates precise share quantity for fixed-risk trades using the formula Shares = Risk Amount / (Current Price – Stop Price), rounded to the nearest whole share, updating in real time on every bar
- Offers two dynamic stop-loss options: Low of Day (LoD) — tracked only during Regular Trading Hours (9:30 AM – 4:00 PM ET) with automatic daily reset — or Low of Week (LoW) via weekly timeframe data
- Displays all critical trade data in a clean, customizable on-screen table showing: Risk Amount, Stop Loss type (LoD/LoW), Stop Price, and calculated Shares Qty
- Allows full table placement control with four corner positions with optional Top Offset and Bottom Offset (0–20 blank rows each) to prevent overlap with price action or other indicators
- Provides complete visual styling control for header text/background, value text/background, and share quantity text/background
- Ensures efficient rendering by recreating the table only when position, row count, or layout changes, deleting the prior instance to avoid flicker or memory issues
- Handles edge cases safely: shows 0 shares if stop is 'na' or above current price, and initializes LoD only on the first RTH bar of each session
- For use on equities only (table will not display on futures instruments)
--
Future improvements: - Visual Stop Loss line for either LoD or LoW
- Functionality and toggle to include Extended hours (PM /AH) for LoD stop pricing
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.