OPEN-SOURCE SCRIPT
Close All Positions

Close All Positions is a lightweight, time‑based exit tool for TradingView. Add it to any chart and tell it exactly when (hour + minute + timezone) you want every open position on that symbol closed. When the clock matches your settings, the script:
1. Fires a one‑time alert with your custom message (perfect for routing to a broker via webhook).
2. Drops a ▼ label on the bar where the exit signal occurred, time‑stamped in the tooltip for easy verification.
Key settings
Time: Choose any hour (1‑24) and minute (0‑59) for the exit trigger.
Timezone: Select the reference zone (e.g., UTC‑5) so your end‑of‑day lines up regardless of chart or broker time.
Alert Message: Type the text you want sent in the alert payload—add JSON if a webhook needs extra fields.
Typical use‑cases
End‑of‑Day Flat: Force‑exit intraday trades before the market closes.
Funding Avoidance (Crypto): Close positions just before the funding snapshot.
Risk Controls: Mandate flat exposure at a scheduled portfolio review time.
Tips
For minute‑level precision, run the indicator on a 1‑minute chart. On higher timeframes, the alert fires on the first bar that envelops your chosen minute.
Apply the script to every symbol you trade (or use a multi‑symbol alert group) if you need a blanket portfolio shutdown.
Pair it with a broker integration (TradersPost, etc.) so the alert automatically submits market‑close orders—no manual clicks required.
That’s it! Drop Close All Positions on the chart, set the clock, and let it take the “did I remember to close?” worry off your plate.
1. Fires a one‑time alert with your custom message (perfect for routing to a broker via webhook).
2. Drops a ▼ label on the bar where the exit signal occurred, time‑stamped in the tooltip for easy verification.
Key settings
Time: Choose any hour (1‑24) and minute (0‑59) for the exit trigger.
Timezone: Select the reference zone (e.g., UTC‑5) so your end‑of‑day lines up regardless of chart or broker time.
Alert Message: Type the text you want sent in the alert payload—add JSON if a webhook needs extra fields.
Typical use‑cases
End‑of‑Day Flat: Force‑exit intraday trades before the market closes.
Funding Avoidance (Crypto): Close positions just before the funding snapshot.
Risk Controls: Mandate flat exposure at a scheduled portfolio review time.
Tips
For minute‑level precision, run the indicator on a 1‑minute chart. On higher timeframes, the alert fires on the first bar that envelops your chosen minute.
Apply the script to every symbol you trade (or use a multi‑symbol alert group) if you need a blanket portfolio shutdown.
Pair it with a broker integration (TradersPost, etc.) so the alert automatically submits market‑close orders—no manual clicks required.
That’s it! Drop Close All Positions on the chart, set the clock, and let it take the “did I remember to close?” worry off your plate.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.