Close or reverse on an opposite signal
Your strategy is long and a short signal arrives. You either want to get flat, or get flat and then go short. Autoview treats those as two different jobs. Closing is one command. Reversing is that close followed by a separate entry.
This page comes from the Autoview integrations code that runs on our servers today. It has not been re-run live for this guide.
Closing on the opposite signal
To close a long, send c=position with b=long:
c=position b=longAutoview looks up the open long and sends an order on the other side to close it. Leave q= off and it closes all of it. q=50% closes half, as partial closes by exchange explains, along with the venues that refuse c=position. To close a short, use b=short.
Reversing: close, then a new entry
A line that carries c= with the default opposite=1 only closes or cancels. Autoview returns as soon as the close is sent, so that line never opens the new trade. A reversal from long to short is two commands:
c=position b=long
b=short q=1 t=market
The second line is a normal entry, sized the way you size any other order. You can send the two as two alerts, or put them on two lines of one alert. Autoview splits a message into separate commands at each new line or | character. We have not checked that those lines always run in the order written, so test it first (see the last section).
What opposite= changes
opposite= decides which side the c=position order goes out on.
- opposite=1 is the default. The order goes out on the side that closes the position, and it is marked as a close. You never need to write it.
- opposite=0 adds instead of closing. The order goes out on the position's own side, sized from the position, so it grows the trade. Always send
b=with it. If nothing is open on theb=side, on a flat account or with only the other side open,opposite=0does not stop there. Autoview opens a new position on theb=side, sized like any other entry, and with noq=that size is the defaultq=100%.
Leaving out b= is caught on some venues and not on others. On Bybit, Kraken, Tradovate and the other venues that use Autoview's shared close step, it stops the alert with a missing parameter error while a position is open. On Binance Futures, Binance Delivery, OKX and HTX it is not caught: the order adds to every open position on the symbol. With nothing open, those four refuse it, because a new entry needs b=.
opposite=0 is not a reversal switch. opposite=1 never opens a position. opposite=0 can, when there is nothing on the b= side to add to.
Where we read the code for opposite=0, it adds to the position on Binance Futures, Binance Delivery, OKX, and HTX Futures, HTX Linear and HTX Swap. The Bitget copy-trading connector refuses it with an unsupported feature error, because its close endpoint can only close, and it does not open new orders from an alert either. The Bybit copy-trading connector refuses it the same way while a matching position is open. With nothing open on the b= side, it opens a new position instead. On every other venue, opposite=0 has not been checked to the same standard yet, so test it with d=1 before you use it.
Flat alerts close only on Tradovate
A TradingView strategy that goes to no position can send b=flat. Autoview turns that into c=all, cancel everything and close everything. In the code running today, only the Tradovate connector carries out c=all. On other venues the alert stops with an unsupported feature error and nothing is closed. Outside Tradovate, close with c=position instead. The Tradovate command reference covers the Tradovate side.
Test it once before you rely on it
Add d=1 to every line first. Autoview writes what it would send to your log and places nothing. Check that the close comes before the entry, that the close is on the right side, and that the entry size is what you meant. The log guide shows where to look. When it looks right, take d=1 off. To stop a repeated exit from opening a new position, see reduce-only orders by exchange.