OPEN-SOURCE SCRIPT
Cập nhật Risk Management [odnac]

📌 Overview
This indicator helps you visually manage risk — the most critical aspect of trading. By entering your total capital, risk percentage, and leverage, it automatically calculates the optimal position size, required margin, and risk-to-reward ratio (R:R), and displays everything directly on the chart.
⚙️ Key Features
📋 Input Parameters
💡 Tips
⚠️ Important Notes
Please review the entry detection logic below before using this indicator.
1. Entry signals are triggered by high/low touch, not by candle close.
If the entry price falls within the high-to-low range of the current forming candle, a signal may fire even if the closing price has not yet reached the entry level. Always verify actual order fills manually.
2. A ⚠️ Market Entry warning is shown when a market order is detected.
If the following conditions are met, the indicator assumes a market entry has likely already occurred and displays a warning on the entry label.
B/S signals are not displayed when a market entry is detected. Additionally, the actual fill price may differ from the configured entry price, so always confirm directly.

3. B/S Signal Label Behavior
B (Buy) or S (Sell) signals are only displayed on the chart when limit entry conditions are met. When the indicator detects a market entry (Warning state), it considers the position already entered and therefore no B/S signal label is generated.
🛠️ How to Set Up
This indicator helps you visually manage risk — the most critical aspect of trading. By entering your total capital, risk percentage, and leverage, it automatically calculates the optimal position size, required margin, and risk-to-reward ratio (R:R), and displays everything directly on the chart.
⚙️ Key Features
- Automatic Position Size Calculation — Calculates the optimal entry size based on your configured risk % and stop loss distance.
- R:R Visualization — Displays entry, stop loss, and take profit levels on the chart with colored fill zones and ratio labels at the center.
- Real-time PnL Tracking — Shows live profit/loss (% and amount) with leverage applied in the info table after entry.
- Market/Limit Entry Detection — Automatically displays B/S signals and triggers alerts when price reaches the entry level.
- Multi-Currency Support — Choose from 15 currency symbols including USD, EUR, JPY, and BTC.
- UI Customization — Freely adjust line colors, table position, and transparency to match your chart theme.
📋 Input Parameters
Total Capital Total trading capital
Risk % Maximum loss allowed per trade
Leverage Leverage multiplier
Entry / Stop / TP Set prices by clicking directly on the chart
💡 Tips
- Set your levels in order: Entry → Stop Loss → Take Profit by clicking on the chart.
- It is recommended to only consider trades where R:R is at least 1:2 or higher.
- Always check the position size and required margin to avoid over-leveraging.
- Enable the B/S Signal alert condition to receive notifications at entry and exit points.
⚠️ Important Notes
Please review the entry detection logic below before using this indicator.
1. Entry signals are triggered by high/low touch, not by candle close.
If the entry price falls within the high-to-low range of the current forming candle, a signal may fire even if the closing price has not yet reached the entry level. Always verify actual order fills manually.
2. A ⚠️ Market Entry warning is shown when a market order is detected.
If the following conditions are met, the indicator assumes a market entry has likely already occurred and displays a warning on the entry label.
- Long position — The current candle opened below the entry price
- Short position — The current candle opened above the entry price
B/S signals are not displayed when a market entry is detected. Additionally, the actual fill price may differ from the configured entry price, so always confirm directly.
3. B/S Signal Label Behavior
B (Buy) or S (Sell) signals are only displayed on the chart when limit entry conditions are met. When the indicator detects a market entry (Warning state), it considers the position already entered and therefore no B/S signal label is generated.
🛠️ How to Set Up
- Capital & Risk — Enter your total capital and the risk percentage you are willing to accept per trade.
- Position Settings — Click on the chart in order: Entry Price → Stop Loss → Take Profit to define your range, then confirm.
- UI & Colors — Adjust colors and table position to match your personal chart theme.
Phát hành các Ghi chú
Label Position Improvement — Fixed an issue where labels were fixed to the center of the line during an active position, causing them to be obscured by candles. Labels now stick to the right side of the chart while the position is open, and move back to the center of the line once the position is closed upon reaching TP/SL.Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.