OPEN-SOURCE SCRIPT
[Kpt-Ahab] Assistant: Risk & DCA Planner

Script Description – Assistant: Risk & DCA Planner
The Risk & DCA Planner is a technical assistant for position and risk management.
It automatically calculates, based on volatility (ATR%), swing structure, and your settings:
Core Logic
Risk Profile
Three modes: Low, Normal, High.
These define how reactive the script behaves internally:
Stop-Loss (SL)
Automatically calculated from ATR% and recent swing structure, limited by minimum and maximum thresholds.
The SL percentage defines the R-unit, which all TPs and DCA levels are based on.
Take-Profits (TPs)
Up to six targets, each a multiple of the defined risk (e.g., 1R, 2R, 3R).
Prices are automatically adjusted depending on long or short direction.
DCA Strategy
Optional. Adds scaling levels evenly between Entry and SL or in multiples of the ATR.
Each DCA allocation grows geometrically until the maximum position size is reached.
Suitability Check
Evaluates whether the market is within an appropriate ATR% range and has sufficient volume.
The table displays “OK” or “Caution” depending on volatility and historical consistency.
Visualization
The Risk & DCA Planner is a technical assistant for position and risk management.
It automatically calculates, based on volatility (ATR%), swing structure, and your settings:
- Stop-Loss (SL) and corresponding Take-Profit targets (TPs) in R-multiples
- DCA (Dollar-Cost-Averaging) levels — both price and amount
- A market suitability check (based on volatility & volume)
- Plus a clear table and summary label displayed on the chart
- The script helps you plan risk, scaling, and profit targets consistently and quantitatively.
Core Logic
Risk Profile
Three modes: Low, Normal, High.
These define how reactive the script behaves internally:
- Low → conservative, longer lookbacks, tighter analysis
- Normal → balanced
- High → aggressive, faster reaction, wider stops
Stop-Loss (SL)
Automatically calculated from ATR% and recent swing structure, limited by minimum and maximum thresholds.
The SL percentage defines the R-unit, which all TPs and DCA levels are based on.
Take-Profits (TPs)
Up to six targets, each a multiple of the defined risk (e.g., 1R, 2R, 3R).
Prices are automatically adjusted depending on long or short direction.
DCA Strategy
Optional. Adds scaling levels evenly between Entry and SL or in multiples of the ATR.
Each DCA allocation grows geometrically until the maximum position size is reached.
Suitability Check
Evaluates whether the market is within an appropriate ATR% range and has sufficient volume.
The table displays “OK” or “Caution” depending on volatility and historical consistency.
Visualization
- Lines for SL, TPs, and DCA levels
- A table with all parameters, prices, and risk data
- A chart label summarizing key info (profile, direction, SL%, TPs, DCA, etc.)
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.