OPEN-SOURCE SCRIPT
تم تحديثه Position Size CalC

Auto calculates position size based on preset risk and max allocation
ملاحظات الأخبار
Enhanced Position Size CalC (TradeCalc)Enhanced Position Size CalC is a decision-support indicator designed to turn a chart into a complete trade planning and risk management workspace. It calculates position size, stop loss, and profit targets automatically based on your account parameters, while still allowing full manual control when you need it.
This is not a signal generator. It assumes you choose the trade. The indicator’s job is to answer the harder questions:
Where is my risk? How big should the position be? What does 2R actually mean in dollars and shares?
---
What the Indicator Does
Once applied to a chart, the indicator:
• Determines a logical stop-loss using price structure (support)
• Calculates risk per share and a fixed 2R profit target
• Sizes the position based on account risk % and max allocation rules
• Visually plots Entry, Stop, and 2R Target directly on the chart
• Displays a live position sizing table with shares, tranches, risk, and profit
• Triggers alerts when Stop Loss or 2R Target is hit
Everything updates dynamically with price.
---
Stop-Loss Logic (Auto Modes)
You can choose how the stop loss is calculated:
Smart Support (default)
Scans recent price action to find meaningful support levels based on repeated touches within a lookback window. A buffer (%) is applied below support to reduce stop hunts.
Pivot Low
Uses recent pivot lows for a cleaner, swing-based stop.
Simple Low
Uses the lowest low over a defined lookback. Simple, mechanical, and conservative.
A percentage buffer can be added below any support level.
---
Risk & Position Sizing
Position size is calculated using two independent constraints:
Risk-based sizing
Limits total dollar loss to your defined Risk per Trade (%).
Allocation-based sizing
Caps the position so it never exceeds Max Allocation (%) of your account.
The indicator automatically chooses the smaller of the two and clearly labels when allocation is the limiting factor.
---
Overrides (Full Manual Control)
You can override any part of the automation:
• Entry Price Override – Use a planned entry instead of current price
• Stop Loss Override – Force a custom stop level
• Position Override (Shares) – Fix position size manually
When overrides are active, the table clearly shows MANUAL OVERRIDE mode so nothing is hidden or ambiguous.
---
2R Framework (Risk-Multiple Based)
The indicator is built around a 2R risk model:
• R = Entry − Stop
• 2R Target = Entry + (2 × Risk per Share)
It calculates and displays:
• Exact 2R price level
• Dollar profit at 2R
• Percentage return at 2R
This keeps the focus on expectancy and consistency, not arbitrary price targets.
---
Alerts
Two alerts are available:
Stop Loss Execute
Triggers when price crosses below the active stop level.
2R Target Execute
Triggers when price crosses above the 2R target.
Designed for partial profit taking (e.g., sell 50%).
Alerts use invisible plotted levels, so they remain accurate even if visuals are turned off.
---
Visual Output
On the chart: • Entry line (blue)
• Stop-loss line (red, dashed)
• 2R target line (green)
On the table: • Total position size
• Two 50% tranches
• Dollar risk and real risk %
• 2R profit in dollars and %
• Status flags (Risk Optimized / Allocation Limited / Manual Override)
---
Who This Indicator Is For
• Swing traders and position traders
• Traders who think in R-multiples, not predictions
• Anyone who wants risk defined before clicking buy
• Traders who want discipline without rigidity
---
Important Note
This indicator does not tell you when to trade.
It tells you how much, where you’re wrong, and what success actually pays.
Used correctly, it turns impulsive trades into structured bets—and makes risk visible before it becomes real.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.