OPEN-SOURCE SCRIPT
[Kpt-Ahab] Planned Order Visualizer IND

This Script visualizes planned long or short positions, including an optional existing position size, average entry price, up to three planned entries, a stop-loss level, and an estimated liquidation price. The current position can be treated either as already open or as a new planned entry. In simulation mode, all active entries are included in the calculation immediately, while in live mode only triggered price levels are included. Additional safety settings help prevent historical alerts and can optionally block entry or SL levels that would trigger immediately. The script is designed for planning, visualization, and alerting of planned positions.

**Tips**
* Use **Simulation** mode to preview how all active entries affect the average price before any live alerts are enabled.
* Use **Live** mode only when you want the script to track price-level triggers in real time.
* Keep **Trigger only in realtime** enabled when using alerts, to avoid historical alert triggers after loading the script.
* Use **Block marketable entry limits** and **Block marketable SL** to prevent levels that would trigger immediately.
* Increase the **Reset counter** only when you intentionally want to reset all triggered states and prepare a fresh setup.
* The liquidation price is an estimate for planning purposes and may differ from the exact exchange liquidation price.
This script currently uses a fixed entry structure with `E0` plus `E1`, `E2`, and `E3`. To increase the number of planned entries, duplicate the existing entry blocks and keep the same naming pattern.
For every additional entry, add:
* new input fields for active state, price, and quantity
* new submitted and triggered flags
* average price quantity/value calculations
* price-allowed and price-hit logic
* alert trigger logic
* line and label objects
* table rows if the entry should be shown in the info table
**Tips**
* Use **Simulation** mode to preview how all active entries affect the average price before any live alerts are enabled.
* Use **Live** mode only when you want the script to track price-level triggers in real time.
* Keep **Trigger only in realtime** enabled when using alerts, to avoid historical alert triggers after loading the script.
* Use **Block marketable entry limits** and **Block marketable SL** to prevent levels that would trigger immediately.
* Increase the **Reset counter** only when you intentionally want to reset all triggered states and prepare a fresh setup.
* The liquidation price is an estimate for planning purposes and may differ from the exact exchange liquidation price.
This script currently uses a fixed entry structure with `E0` plus `E1`, `E2`, and `E3`. To increase the number of planned entries, duplicate the existing entry blocks and keep the same naming pattern.
For every additional entry, add:
* new input fields for active state, price, and quantity
* new submitted and triggered flags
* average price quantity/value calculations
* price-allowed and price-hit logic
* alert trigger logic
* line and label objects
* table rows if the entry should be shown in the info table
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.