This is a script we use to close all of our orders or positions on any of the integrated exchanges.
You can use a fire once alert with greater than on condition and the alert will typically fire within seconds. You can also use this to place orders for you without having to navigate away from TradingView to your exchange/brokerage site.
If you would like a better understanding of how to create an alert for automation, please visit the article this strategy is being published for.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.