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.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.