OPEN-SOURCE SCRIPT
SmartFlow Position Sizer

SmartFlow Position Sizer automatically calculates your lot size based on account balance, risk percentage, and stop loss distance. Just click twice — Entry and SL — and let the math do the work. No spreadsheets. No guessing. Trade with discipline.
═══════════════════════════════════════
█ WHAT IT DOES
This indicator solves the most common mistake in trading: incorrect position sizing.
You set your account balance and risk %. Then click your Entry and Stop Loss directly on the chart. The indicator instantly calculates:
═══════════════════════════════════════
█ HOW TO USE
Step 1 — Add the indicator to your chart
Step 2 — Click on the chart to set your Entry Price (1st click)
Step 3 — Click again to set your Stop Loss (2nd click)
That's it. The table and SL/TP zones appear immediately.
═══════════════════════════════════════
█ TABLE DISPLAY
The on-chart table shows everything at a glance:
═══════════════════════════════════════
█ VISUAL ZONES
Zones are drawn between your click positions, not fixed to the latest bar. This means you can place Entry and SL anywhere on the chart — including future empty areas — to plan trades visually before price arrives.
═══════════════════════════════════════
█ LOT CALCULATION FORMULA
Lot = (Balance × Risk%) / (SL Distance × Contract Size)
Example: $10,000 balance, 2% risk, SL distance = $20, contract size = 100
→ Lot = ($10,000 × 0.02) / ($20 × 100) = 0.10 lots
The result is rounded down to the nearest 0.01 to avoid exceeding your risk limit.
═══════════════════════════════════════
█ SETTINGS
Account Settings
Take Profit
ATR Volatility
Display
═══════════════════════════════════════
█ NOTES
═══════════════════════════════════════
█ WHAT IT DOES
This indicator solves the most common mistake in trading: incorrect position sizing.
You set your account balance and risk %. Then click your Entry and Stop Loss directly on the chart. The indicator instantly calculates:
- Lot size — based on your risk tolerance and SL distance
- Take Profit — auto-calculated from your R:R ratio
- P&L in USD — expected profit and max loss displayed
- ATR volatility — current vs average ATR to gauge market conditions
- Long/Short auto-detection — determined by Entry vs SL position
═══════════════════════════════════════
█ HOW TO USE
Step 1 — Add the indicator to your chart
Step 2 — Click on the chart to set your Entry Price (1st click)
Step 3 — Click again to set your Stop Loss (2nd click)
That's it. The table and SL/TP zones appear immediately.
- Drag the Entry or SL line to adjust — all calculations update in real time
- Change R:R ratio in settings to move the TP level
- Long or Short is detected automatically — no manual selection needed
- Works in future (empty) chart areas — plan trades before price arrives
═══════════════════════════════════════
█ TABLE DISPLAY
The on-chart table shows everything at a glance:
- ATR — current ATR value with period
- ATR Avg — average ATR for volatility comparison
- Vol Ratio — current ATR / average ATR (orange when elevated)
- Balance — your account balance in USD
- Risk % — max loss percentage per trade
- Entry — entry price with LONG/SHORT label
- Lot — calculated position size
- R:R — risk-to-reward ratio
- TP — take profit price and expected profit in USD
- SL — stop loss price and max loss in USD
═══════════════════════════════════════
█ VISUAL ZONES
- White line — Entry price
- Red zone — SL area (loss zone) with dollar amount on label
- Green zone — TP area (profit zone) with dollar amount on label
Zones are drawn between your click positions, not fixed to the latest bar. This means you can place Entry and SL anywhere on the chart — including future empty areas — to plan trades visually before price arrives.
═══════════════════════════════════════
█ LOT CALCULATION FORMULA
Lot = (Balance × Risk%) / (SL Distance × Contract Size)
Example: $10,000 balance, 2% risk, SL distance = $20, contract size = 100
→ Lot = ($10,000 × 0.02) / ($20 × 100) = 0.10 lots
The result is rounded down to the nearest 0.01 to avoid exceeding your risk limit.
═══════════════════════════════════════
█ SETTINGS
Account Settings
- Balance (USD) — Your account balance. Default: 10,000
- Risk per Trade (%) — Max loss per trade. Default: 2%
- Contract Size (per Lot) — MT5 contract size. XAUUSD = 100. Adjust for your broker
Take Profit
- R:R Ratio — TP is calculated as SL distance × this value. Default: 1.5
ATR Volatility
- ATR Period — Default: 14
- ATR Average Period — For comparing current volatility vs average. Default: 50
Display
- Table position (4 corners), text size, SL/TP zone toggle
═══════════════════════════════════════
█ NOTES
- Works on any instrument — Gold, Forex, Crypto, Indices
- Designed for MT5/MT4 lot sizing — adjust Contract Size for your broker
- ATR volatility ratio turns orange when current ATR exceeds 1.5x the average — a visual warning that volatility is elevated
- All calculations use USD-denominated accounts
- Drawing positions use time-based coordinates, enabling placement in future chart areas
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
SmartFlow Pro — SMC detection (OB/BOB, FVG/iFVG, OTE, Confluence, Alerts) +
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
SmartFlow Pro — SMC detection (OB/BOB, FVG/iFVG, OTE, Confluence, Alerts) +
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.