This guide demonstrates how to configure a timed position-closing script that triggers market-closing signals during specific hours—ideal for automating trades while you sleep or work. By connecting to TVCBOT's full-position liquidation signal, the system ensures hands-free position management.
Core Functionality
The Pine Script below generates closing signals at user-defined times when paired with a 1-minute TradingView chart:
//@version=5
indicator("TVCBOT Timed Position Close", overlay=true)
h = input.int(00, "Close Hour", minval=0, maxval=23, step=1)
m = input.int(00, "Close Minute", minval=0, maxval=59, step=1)
offset = input.int(8, "Timezone (Default UTC+8)", minval=-20, maxval=20)
// Note: Script uses UTC+8 by default.
label1 = label.new(bar_index, low, text="Current Time - " + str.tostring(hour+offset) + ":" + str.tostring(minute), style=label.style_label_up, color=color.white)
label.set_x(label1, bar_index)
label.delete(label1[1])
alertcondition(hour+offset==h and minute==m, title='Timed Close Signal', message='Timed Close Signal')Configuration Steps
1. Script Setup
- Copy the code into TradingView’s Pine Editor.
- Apply it to a 1-minute chart of your trading pair.
2. Time Adjustment
- Click the indicator’s settings icon (top-left).
- Set your desired closing hour/minute under
Close HourandClose Minute. - Adjust
Timezoneif needed (default: UTC+8).
3. Alert Creation
- Click "Alert" → "Create Alert".
In TVCBOT:
- Navigate: Account → Select Trading Pair → Choose Indicator.
- Select "Market Close All" and your margin mode.
- Generate the alert and copy its message.
- Paste the message into TradingView’s "Message" field.
- Under "Notification", add TVCBOT’s WebHook URL.
👉 Optimize your alerts with TVCBOT’s advanced tools
Managing Alerts
- Active Alerts: Listed on the left panel; delete to stop auto-closing.
- Troubleshooting: Ensure chart timeframe matches script requirements (1-minute).
FAQ
Q1: Can I set multiple closing times?
No. The script triggers once daily at the specified time. For multiple intervals, duplicate the script with different settings.
Q2: Why isn’t my alert triggering?
- Verify the timezone offset matches your location.
- Check that the chart’s timeframe is 1-minute.
Q3: Is this script compatible with all exchanges?
Yes, but ensure your exchange supports API integrations via TVCBOT.
👉 Explore supported exchanges here
Pro Tips
- Test the script during low-volatility periods to avoid unintended liquidations.
- Combine with TradingView’s strategy tester to backtest timing accuracy.
By following these steps, you’ll automate position closures seamlessly—whether for risk management or schedule flexibility. Always double-check timezone and exchange compatibility before deployment.