OPEN-SOURCE SCRIPT
Risk Manager & ATR TS Strategy

📌 Overview
This script is not a simple indicator mashup. It is a Risk & Trade Planning Engine that combines a strategy-based signal generator with a snapshot-based risk, sizing, and expectancy model. It is designed to support real trading decisions, not just to generate cosmetic signals or overfitted backtests.
The core idea is to separate market logic from risk logic, evaluating each trade only at the moment it becomes actionable using fixed reference points that do not change afterward.
🎯 What makes this script original Unlike most tools that merely combine indicators or visualize entries, this script introduces several non-standard design choices:
Snapshot-based risk sizing (The "Time Machine" logic).
Expected Value (EV) calculation in both Money and R-multiples.
Kelly Criterion applied with weighted multi-target logic.
Strict architectural separation between the signal engine and the risk engine.
Decision-oriented dashboard instead of decorative plots.
These components are not merged for convenience; they are architecturally dependent on each other.
🧠 Conceptual Architecture
1️⃣ Signal Engine (Market Context) The signal engine is based on an ATR Trailing Stop system combined with trend regime filters (ADX and Choppiness Index). Its only responsibility is to answer one question: "Is this a valid directional opportunity right now?" It does not manage risk; it only identifies the opportunity.
2️⃣ Snapshot Logic (Key Design Choice) When a valid signal occurs, the script captures a Snapshot of the Entry price, Initial Stop-Loss, and Risk Distance. This snapshot is frozen at signal time. It is never updated, even if the trailing stop moves later. This avoids the most common error in TradingView scripts: recalculating position size using a moving stop, which falsifies the risk data.
3️⃣ Risk Engine (Sizing & Control) Using the snapshot values, the script computes:
Monetary risk per trade (capped at your user-defined max).
Position size derived from the fixed stop distance.
Effective leverage (informational).
4️⃣ Multi-Target Reward Model Instead of assuming a single take-profit, the script supports multiple targets with user-defined probability weights. From this, it derives a Weighted Risk/Reward Ratio, which feeds directly into the EV and Kelly calculations.
5️⃣ Expected Value (EV) in Money & R The script calculates EV in your account currency (real impact) and normalized in R-multiples (statistical quality). This allows you to compare trade quality across different assets and timeframes objectively.
6️⃣ Kelly Criterion (Conservative) The Kelly Criterion is applied using the weighted reward model and is always subordinated to your hard risk cap. If Kelly suggests a negative value, the script advises "NO TRADE". It is used as a filter, not a leverage amplifier.
📊 Dashboard & Alerts The on-chart dashboard summarizes everything you need at the moment of the signal:
Risk % and Position Size
Expected Value (Money + R)
Kelly Suggestion
Signal Strength
Alerts are triggered once per signal (on bar close) using snapshot data, ensuring no repainting and no spam.
🔍 How this is NOT a mashup Each component exists because another component depends on it. Snapshot logic is required for valid risk sizing; Risk sizing is required for EV normalization; Weighted RR is required for meaningful Kelly. Removing any part breaks the system’s logic.
📘 How to use
Choose your account size and risk parameters in the settings.
Configure your stop logic and reward targets.
Wait for a valid signal.
Evaluate the dashboard: Decide if the trade quality (EV, R, Risk) justifies participation.
⚖️ Open-Source Notice This script is published under the Mozilla Public License 2.0 (MPL-2.0). It does not copy or replicate any single public script. Standard concepts (ATR, ADX) are used as building blocks, but the architecture and calculations are original.
🚫 Disclaimer This script is a planning and evaluation engine designed to help traders think in terms of risk, expectancy, and discipline. It does not guarantee profitability.
✅ Summary This is a professional-grade framework built to answer one core question: “Is this trade worth taking, given my risk and my expectations?” Not every signal is a trade, and not every trade deserves capital. This script helps you make that distinction.
This script is not a simple indicator mashup. It is a Risk & Trade Planning Engine that combines a strategy-based signal generator with a snapshot-based risk, sizing, and expectancy model. It is designed to support real trading decisions, not just to generate cosmetic signals or overfitted backtests.
The core idea is to separate market logic from risk logic, evaluating each trade only at the moment it becomes actionable using fixed reference points that do not change afterward.
🎯 What makes this script original Unlike most tools that merely combine indicators or visualize entries, this script introduces several non-standard design choices:
Snapshot-based risk sizing (The "Time Machine" logic).
Expected Value (EV) calculation in both Money and R-multiples.
Kelly Criterion applied with weighted multi-target logic.
Strict architectural separation between the signal engine and the risk engine.
Decision-oriented dashboard instead of decorative plots.
These components are not merged for convenience; they are architecturally dependent on each other.
🧠 Conceptual Architecture
1️⃣ Signal Engine (Market Context) The signal engine is based on an ATR Trailing Stop system combined with trend regime filters (ADX and Choppiness Index). Its only responsibility is to answer one question: "Is this a valid directional opportunity right now?" It does not manage risk; it only identifies the opportunity.
2️⃣ Snapshot Logic (Key Design Choice) When a valid signal occurs, the script captures a Snapshot of the Entry price, Initial Stop-Loss, and Risk Distance. This snapshot is frozen at signal time. It is never updated, even if the trailing stop moves later. This avoids the most common error in TradingView scripts: recalculating position size using a moving stop, which falsifies the risk data.
3️⃣ Risk Engine (Sizing & Control) Using the snapshot values, the script computes:
Monetary risk per trade (capped at your user-defined max).
Position size derived from the fixed stop distance.
Effective leverage (informational).
4️⃣ Multi-Target Reward Model Instead of assuming a single take-profit, the script supports multiple targets with user-defined probability weights. From this, it derives a Weighted Risk/Reward Ratio, which feeds directly into the EV and Kelly calculations.
5️⃣ Expected Value (EV) in Money & R The script calculates EV in your account currency (real impact) and normalized in R-multiples (statistical quality). This allows you to compare trade quality across different assets and timeframes objectively.
6️⃣ Kelly Criterion (Conservative) The Kelly Criterion is applied using the weighted reward model and is always subordinated to your hard risk cap. If Kelly suggests a negative value, the script advises "NO TRADE". It is used as a filter, not a leverage amplifier.
📊 Dashboard & Alerts The on-chart dashboard summarizes everything you need at the moment of the signal:
Risk % and Position Size
Expected Value (Money + R)
Kelly Suggestion
Signal Strength
Alerts are triggered once per signal (on bar close) using snapshot data, ensuring no repainting and no spam.
🔍 How this is NOT a mashup Each component exists because another component depends on it. Snapshot logic is required for valid risk sizing; Risk sizing is required for EV normalization; Weighted RR is required for meaningful Kelly. Removing any part breaks the system’s logic.
📘 How to use
Choose your account size and risk parameters in the settings.
Configure your stop logic and reward targets.
Wait for a valid signal.
Evaluate the dashboard: Decide if the trade quality (EV, R, Risk) justifies participation.
⚖️ Open-Source Notice This script is published under the Mozilla Public License 2.0 (MPL-2.0). It does not copy or replicate any single public script. Standard concepts (ATR, ADX) are used as building blocks, but the architecture and calculations are original.
🚫 Disclaimer This script is a planning and evaluation engine designed to help traders think in terms of risk, expectancy, and discipline. It does not guarantee profitability.
✅ Summary This is a professional-grade framework built to answer one core question: “Is this trade worth taking, given my risk and my expectations?” Not every signal is a trade, and not every trade deserves capital. This script helps you make that distinction.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.