# Close / Reverse

<figure><img src="https://554260309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeAkMGtCw51BYWLVdmuDx%2Fuploads%2FgrmTJcTzz48BqBD3yuBH%2Fimage.png?alt=media&#x26;token=1c2c98ef-47ad-48f7-8b1c-eb6901fd28b8" alt="" width="563"><figcaption></figcaption></figure>

In a <mark style="color:green;">LONG</mark> position, the position is **closed** when a <mark style="color:red;">sell↓</mark> signal is received, for example:

```
{
  "name": "Hook 196",
  "secret": "2ehiexig0r5",
  "side": "sell",
  "symbol": "{{ticker}}"
}
```

In a <mark style="color:red;">**SHORT**</mark> position, the position is **closed** when a <mark style="color:green;">**buy↑**</mark> signal is received, for example:

```
{
  "name": "Hook 196",
  "secret": "2ehiexig0r5",
  "side": "buy",
  "symbol": "{{ticker}}"
}
```

{% hint style="warning" %}
The position will also be closed if TradingView strategy sends <mark style="color:blue;">**"positionSide": "flat"**</mark> instead of <mark style="color:green;">**long**</mark> or <mark style="color:red;">**short.**</mark>
{% endhint %}

## 1. Enabled

If enabled, upon receiving a closing signal, an order will be created to close the position.

{% hint style="warning" %}
When the left checkbox is selected, the value is sourced from TradingView signal, not the terminal settings. [Details ->](https://docs.finandy.com/algo-trading/signals-tradingview/controlling-an-option-in-the-signal)
{% endhint %}

## 2. Order type

{% content-ref url="../../../trading/create-order-grid/order-types" %}
[order-types](https://docs.finandy.com/trading/create-order-grid/order-types)
{% endcontent-ref %}

## 3.1 Partial position closing

Select "**Close/reverse by amount in signal**".

<figure><img src="https://554260309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeAkMGtCw51BYWLVdmuDx%2Fuploads%2FsARTHebu0iJMHuqnDZAF%2Fimage.png?alt=media&#x26;token=b688980f-34fe-4216-b9f6-21d84eba0836" alt="" width="563"><figcaption></figcaption></figure>

By using the drop-down menu, you can select the method for calculating the closing quantity in the order.

* **Open Amount + Position Amount**

  Used for [position reversal](#3.3.-position-reversal).
* **Amount**\
  Specify the token quantity (contracts) for the created order in the right-hand field.\
  For example, if you enter <mark style="color:red;">**100**</mark> for **XRPUSDT**, an order for <mark style="color:red;">**100 XRP**</mark> will be placed.
* **Volume**\
  Order quantity (volume) is specified.\
  For example, entering <mark style="color:red;">**0.01**</mark> for **LTCBTC** pair will place an order with a volume of <mark style="color:red;">**0.01 BTC.**</mark>
* **Volume, USD**\
  Order quantity (volume) is specified in dollars.\
  For example, if <mark style="color:red;">**100**</mark> is specified for the **LTCBTC** pair, an order with a volume equivalent to <mark style="color:red;">**$100**</mark> will be created.
* **Full balance %**\
  Orders are created based on a percentage of the total balance.(wallet balance + position volume + position PnL).\
  For example, with 1000 USDT in the wallet, 2000 USDT in positions, a PnL of 100 USDT, and a specified 10% balance, the order will be created for (1000 + 2000 + 100) x 10 / 100 = <mark style="color:red;">**310 USDT.**</mark>

{% hint style="info" %}
The full balance includes all tokens in your account. For instance, if your wallet holds 100 BUSD and 100 USDT, the total balance would be 200.
{% endhint %}

* **Full Balance% х Leverage**\
  Just like in the previous example, but the obtained amount is multiplied by the leverage. From the example above, with a leverage of **5x** the order amount would be <mark style="color:red;">**1550 USDT.**</mark>
* **Free Balance, %**\
  Orders are created based on a percentage of the available balance in the specified market.\
  For example, with <mark style="color:red;">**500 USDT**</mark> in your wallet, <mark style="color:red;">**100 USDT**</mark> in positions, and a **10%** balance specification, the order will be created for an amount of (500 - 100) x 10 / 100 = <mark style="color:red;">**40 USDT.**</mark>
* **Free Balance % х Leverage**\
  Just like in the previous example, but the obtained amount is multiplied by the leverage.\
  For example, using the data from the previous item and a **7x** leverage, the order amount will be \*\*40\*7= \*\*<mark style="color:red;">**280 USDT.**</mark>
* **Position volume, %**\
  A value between <mark style="color:red;">0</mark> and <mark style="color:red;">100</mark> is specified.\
  For instance, if you specify <mark style="color:red;">50</mark>, it will partially close the position by half.\
  If you specify <mark style="color:red;">100</mark>, it will completely close the position.
* **Position volume + balance %**\
  Used for [position reversal](#3.3.-position-reversal).
* **Position volume + (balance % x leverage)**\
  Used for [position reversal](#3.3.-position-reversal).

## 3.2. Total position closing

Select "**Close position completely**".

<figure><img src="https://554260309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeAkMGtCw51BYWLVdmuDx%2Fuploads%2FlD7tIG6ggw7dUSZqKile%2Fimage.png?alt=media&#x26;token=4a80ed84-8285-4207-8682-84a7e39c926f" alt="" width="563"><figcaption></figcaption></figure>

## 3.3. Position reversal

{% hint style="info" %}
This option is only available for the Futures Market in one-way mode (non-hedging).
{% endhint %}

When enabled, upon receiving a closing signal, a reverse position will be created for either the signal quantity or the current position quantity.

{% hint style="warning" %}
When enabling position reversal, it is important to deactivate the hedge mode on the exchange and activate the one-way mode.
{% endhint %}

### By signal amount

When selecting this option, you can configure the amount for position reversal:

1. **Open amount + Position amount**\
   For example, if there is $**100** remaining in a position after a partial close, and the opening amount specified in the signal is $**500**, when the close signal is received, a $**600** order will be created. This order will close the current position and open a new position of $**500** in the opposite direction.
2. **Amount**\
   A reverse order will be created for the specified number of tokens (contracts). For example, if the <mark style="color:green;">LONG</mark> position in the **XRPUSDT** pair specifies **100**, it means that when a <mark style="color:red;">SELL</mark> signal is received, an order for **100 XRP** will be created to close the position.
3. **Volume**\
   A reversal order will be created for the specified amount. For example, if you have a <mark style="color:green;">LONG</mark> position in the **LTCBTC** pair and you specify **0.01**, a <mark style="color:red;">SELL</mark> signal will trigger an order to sell **0.01 BTC.**
4. **Volume, USD**\
   A reversal order will be created for the specified dollar amount. For example, if you specify **100** in the **LTCBTC** pair, an order will be created with a volume equivalent to **$100.**
5. **Balance, %**\
   A closing order will be created based on a percentage of the total balance, which includes (wallet balance + position volume + and position PnL).

   For example, with 1000 USDT in the wallet, 2000 USDT in positions, a PnL of 100 USDT, and a specified 10% balance, the order will be created for (1000 + 2000 + 100) x 10 / 100 = **310 USDT.**
6. **Balance % x Leverage**\
   Just like in the previous example, but the obtained amount is multiplied by the leverage.\
   From the example above, with a leverage of **5x** the order amount would be **1550 USDT.**
7. **Position amount, %**\
   When a signal is received, the position is closed based on the specified percentage.
8. **Position amount + balance %**\
   When a signal is received, the current position will be closed, and a new position will be opened based on a percentage of the balance.
9. **Position amount + (balance % x Leverage)**\
   When a signal is received, the current position will be closed, and a new position will be opened based on a percentage of the balance multiplied by the leverage.

### By position amount

When a signal is received, a reversal order will be created, which is equivalent to doubling the current position. This results in closing the current position and opening a new one with the same quantity.

<figure><img src="https://554260309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeAkMGtCw51BYWLVdmuDx%2Fuploads%2F0iKyzVlBCZDXB1oT3g4J%2Fimage.png?alt=media&#x26;token=7e08dcb9-f3d2-4b7e-ac0b-0738b5880a12" alt="" width="563"><figcaption></figcaption></figure>

## Limits

<figure><img src="https://t24536365.p.clickup-attachments.com/t24536365/980ff148-04d2-4d1d-9218-666aac566b1f/image.png" alt="" width="563"><figcaption></figcaption></figure>

## Check profit

If enabled, unprofitable positions will remain open when the close signal is received.

## Bulk operations

<figure><img src="https://t24536365.p.clickup-attachments.com/t24536365/89dc1a36-22d1-44d9-83f5-d84e0b8f3ca4/image.png" alt="" width="563"><figcaption></figcaption></figure>

## Close ALL positions

If this parameter is enabled and a closing signal is received, all open positions in this market will be closed based on the **Limit/Position** settings:

* **Both**\
  Will close all positions on this market.
* **Only Long**\
  Will close all Long positions on this market.
* **Only Short**\
  Will close all Short positions on this market.

If a signal is sent with "`positionSide": "flat`", then all positions on that pair in that market will be closed. For example:

```
{
  "name": "Hook 72767",
  "secret": "dy2uuc5bih8",
  "side": "buy",
  "symbol": "XRPUSDT",
  "positionSide": "flat"
}
```

## Controlling options in the signal

{% content-ref url="../controlling-an-option-in-the-signal" %}
[controlling-an-option-in-the-signal](https://docs.finandy.com/algo-trading/signals-tradingview/controlling-an-option-in-the-signal)
{% endcontent-ref %}

**Do you have any questions? We can help you in our Telegram chat room.**

{% embed url="<https://t.me/finandy>" %}
