How to Set Up Automatic Position Closing for Exchange Contracts Using TVCBOT and TradingView

·

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

2. Time Adjustment

3. Alert Creation

  1. Click "Alert""Create Alert".
  2. In TVCBOT:

    • Navigate: AccountSelect Trading PairChoose Indicator.
    • Select "Market Close All" and your margin mode.
    • Generate the alert and copy its message.
  3. Paste the message into TradingView’s "Message" field.
  4. Under "Notification", add TVCBOT’s WebHook URL.

👉 Optimize your alerts with TVCBOT’s advanced tools


Managing Alerts


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?

Q3: Is this script compatible with all exchanges?

Yes, but ensure your exchange supports API integrations via TVCBOT.

👉 Explore supported exchanges here


Pro Tips

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.