Webhook Signals: Open, Increase, Reduce, Close or Reverse a Position
The Webhook Signals described in this section are related to positions on a Webhook-type Signal Bot. The signals can be sent from an Altrady Alert or Trading View.
Positions can be opened, increased, reduced, closed, or reversed using a webhook signal.
To generate JSON code for a basic signal, try the Webhook Builder tab in the Signal bot, next to the Settings tab.
Webhook Signals: Webhook Builder
Example signal including only Settings required
Minimum Required Settings for an Open Signal
Example of an Open signal including all required and optional settings
Optional Settings for the Open (and Reverse) Signals
Open (and Reverse) Signal Structure
Minimum Required Settings for an Increase Signal
Example Increase Signal
Optional Settings for the Increase Signal
Increase Signal Structure
Minimum Required Settings for a Reduce Signal
Example Reduce Signal
Optional Settings for the Reduce Signal
Reduce Signal Structure
Minimum Required Settings for a Close Signal
Example Close Signal
Optional Settings for the Close Signal
Close Signal Structure
Minimum Required Settings for a Reverse Signal
Example Reverse Signal
Reverse Signal Structure
- Open: Opens a new position (long or short).
- Increase: Increases the size of an existing position.
- Reduce: Decreases the size of an existing position.
- Close: Closes a specified position.
- Reverse (Futures Only): Closes the current position and opens a new position in the opposite direction.
Each webhook signal must include the following settings:
For a detailed list of valid exchange and symbol values, see: Webhooks: Valid Values for Exchange and Symbol.
An Open signal is used to open a new position. For the signal to be received and executed, the following conditions must be met:
The API key and secret must match those in the Bot Settings.
The signal must be formatted in valid JSON.
The signal must meet all filter criteria in the Signal Bot settings.
Apart from the 5 settings that are required for all Signal Types, (see above), the only additional setting that is required for an Open signal is "side"
For side valid options are long or short.
Use long for a position that opens with a Buy entry and closes with Sell exit/s.
Use short for a position that opens with a Sell entry and closes with Buy exit/s.
Short positions can be opened on Futures exchanges using the quote currency
Short positions can be opened on Spot exchanges if the coins (base currency) are already owned and available to be sold
DCAs, TP/s and SL for your signals can either be:
included in your webhook entry signal (see above). Useful when they will vary with each signal or each market.
specified in the Signal Bot Settings . Useful when they will not vary for each market and signal; or
added manually to your positions once they have opened. Useful for manual intervention, or when these values may vary, and the TV alert does not provide these details.
Choose Custom in the Bot Settings, to specifiy the value in the Bot.
Use Signal in the Bot Settings, to use the values provided in the signal.
TP position_percentages should add to 100. If the sum is less than 100%, the remaining amount will be included in the last TP.
SL 7.5% from entry, with no cooldown
Stop Loss (20% from entry) with 4 hour Candle Close cooldown and Emergency Stop Loss (35% from entry)
Fixed price SL at 2.79, with 10 minute Timer Cooldown, and Emergency Stop Loss (at 2.59 fixed price)**
Fixed price SL at 0.00000100, with 1 hour Timer Cooldown, and TSL>Follow Price, trigger price 3% above the entry price and trailing stop 1% below the trigger price (long position; note for a short position, the trigger price would automatically be below the entry price, and stop price above the trigger price)
The Increase signal is used to increase the position size of one or more open positions, for a single market and side
It will increase the size of existing position/s for the specified market and side, that were opened by the Signal Bot.
Example of an Increase signal including minimum required settings:
One increase_order block must be included, and only one.
"quantity_percentage" OR quote_amount OR base_amount This is a numeric value. Use ONE of these to specify the increase amount. If more than one is included, the signal is rejected. Note: for the pair BTC/USDT, BTC is the base currency and USDT is the quote currency.
.. "quantity_percentage"
increases the position size by a percentage of the initial entry order size. For example, set to 100 to increase the position size by the same amount as the initial entry order.
.. "quote_amount"
increases the position size by the amount of quote currency specified (rounded down to the highest possible order size).
.. "base_amount"
increases the position size by the amount of base currency specified (e.g. 250 would be specified for 250 ADA, for BIFU_USDT_ADA).
The example below uses the Trading View variable {{ close }} to insert the price at the candle close
"order_type" is optional and can be "limit" or "market". If excluded, it will default to limit. For a limit increase order, "price" can be specified.
If "market" is used for "order_type", the order will be placed as a market order and the "price" field (if included) will be ignored.
`price `can be a numeric value, or a Trading View variable such as {{close}} (TV only).
The reduce signal is used to reduce the position size of one or more positions opened by the signal bot, for the specified market and side
reduce will partially close matching open positions by the amount specified in the signal.
Once the reduce signal is received by the bot, for each position that matches the signal symbol and side:
all open Take Profit orders are cancelled .
A new order is created for the specified amount in the reduce block
Each existing TP is reduced proportionally and placed again at the original price
For example:
Existing TPs at [price (%)]: 105 (20%), 115 (30%), 125 (50%)
A reduce signal to close 10% of the position at market price is received
New TPs: 10% (market order), limit orders at: 105 (18%), 115 (27%), 125 (45%)
"action": "reduce"
The API key and Secret must match those in the Bot Settings.
Exchange and Symbol must be specified.
One reduce_order block must be included, and must include the amount to close, either as a percentage of the open size, or an amount of base or quote currency.
Note that, only filled entry orders count in the open position size.
Order Size
"percentage" OR "quote_amount" OR "base_amount". This is a numeric value. Use ONE of these to specify the reduce amount. If more than one is included, the signal will be rejected. Note: for the pair BTC/USDT, BTC is the base currency and USDT is the quote currency.
.. percentage
reduces the position size by a percentage of the initial entry order size. For example, set to 100 to reduce the position size by the same amount as the initial entry order.
.. quote_amount
reduces the position size by the amount of quote currency specified (rounded down to the highest possible order size).
.. base_amount
reduces the position size by the amount of base currency specified (e.g. 250 would be specified for 250 ADA, for BIFU_USDT_ADA).
The example below creates a market TP order for 25.5 ADA.
"order_type" is optional and can be "limit" or "market". When used, order_type must be inside the reduce_order block (see above).
If excluded, order_type will default to limit. For a limit reduce order, price is optional.
If "market" is used for "order_type", the order will be placed as a market order.
price can be a numeric value or a Trading View variable such as {{close}} (TV only).
The Close signal is used to close running position/s for the specified market, that were opened by the same Signal Bot.
A signal with the close action will close the position/s regardless of whether any entry orders have been filled.
The following criteria must be met:
The API key and Secret must match those in the Bot Settings.
"action": "close" is required
Exchange and Symbol must be specified.
This signal would close all open long positions for XBT/USD, that were opened by the Signal Bot.
`action `must be close.
"order_type": "market"` or "order_type": "limit" is required for a close signal.
"order_type": "market" cannot be combined with "price". It will close the current position/s using a pseudo-market order (a limit order 10% from the current price).
"order_type": "limit" must be used with "price". It will close the position with a limit order at the specified price.
side . If omitted, side will default to "long". The side refers to the side of the original position when it was opened. Either long positions or short positions can be closed with one signal, not both.
signal_ID If used, this must be the signal_ID of the signal that opened the specific position.
When the signal_ID is omitted, all positions for the specified market and side, and that were opened by the Signal Bot, will be closed.
Where there might be more than one position open for the same Symbol and Side, signal_ID is used to specify a specific position to close. Since it must match the signal_ID that opened the position, this is not possible with standard Trading View indicators. It might be possible to code using PineScript.
Note. If a Signal_ID was not specified with the original Signal, Altrady will have created a unique signal_ID for the signal. Trading View will not have access to an Altrady-generated Signal_ID
If your bot has a Setting of "Max per market" = 1 , then only one position will ever be opened for one market at the same time. In that case, the Close signal will close that single position, and the Signal_ID is not needed.
The Reverse signal can only be used for Futures markets.
The following example will close any existing short positions, and open a new long position for BTC/USDT on Binance.
Other than the "action": "reverse", all settings for the reverse signal are identical to the required and optional settings for the Open Signal .
The Reverse signal is like a combination of two signals in one: `close `and open.
close the existing position(s) with a market order and open a new position with the given parameters.
The new position will not be opened until the existing position is closed.
For side : valid options are "long" or "short". This will be the side of the new position created. If omitted, it will default to "long".
It will retry up to 5 times with a 3 second delay before failing. This happens asynchronously so the webhook will return immediately, Returns 204 no content when the request is successfully received, otherwise returns the same error messages as the open action.
Use of the Reverse signal is recommended over sending independent close and open signals. With separate signals, the timing of the close is unknown; if the close is not completed on the exchange before the open signal arrives, the Open signal will be ignored, unless hedge mode is enabled and two positions per market are allowed in the bot settings. Additionally, only one signal can be sent in a single TV alert message, so a second alert would be needed for the open signal.
If the position is already closed when the reverse action is received, it will just open a new position with the given settings.
Further details for the Reverse signal can be seen under Open Signal.
For more details, see: Open (and Reverse) Signal Structure
For TradingView alerts, use the webhook URL: https://api.altrady.com/v2/signal_bot_positions.
To simply set up the creation of an order by price crossing or by crossing a trend line as above does not require any programming skills, but if you need to connect an indicator or a strategy, you will need basic knowledge of creating a signal in Pine Script. There is a lot of information on the web about how to generate a signal in Pine.
You can also search on, and ask for advice from, the Pine Scripters Telegram User Group .
TTP is only available on the last indicator("Altrady webhook signal")
With "test": true, your webhook signal in combination with your bot, should create Pending orders that you can see on the chart and in My Orders.
Note: "test": true ONLY works with Open signals. For other signal types, this will be ignored and a live order will be sent.
Once you are ready to send live signals, change the first line to: test = input.bool(false, "Test signal")`

Please change the API Key and Secret and also make sure you set the correct exchange and symbol
Please ensure the Signal ID is unique per bot. Using the {{ time }} will ensure a unique signal ID each second ---
Webhook and Trading View Signals: Overview
Webhook: Setting up the Signal Bot
Webhook Signals: Webhook Builder
Webhook Signals: start or stop a Signal Bot
Valid values for Exchange and Symbol
Webhook Signals: Trading View Setup
Webhook Signals: Testing and Errors
Positions can be opened, increased, reduced, closed, or reversed using a webhook signal.
To generate JSON code for a basic signal, try the Webhook Builder tab in the Signal bot, next to the Settings tab.
Webhook Signals: Webhook Builder
Contents
Types of Position Signals
Required Settings for all Signal Types
Example signal including only Settings required
Open Signal
Minimum Required Settings for an Open Signal
Example of an Open signal including all required and optional settings
Optional Settings for the Open (and Reverse) Signals
Open (and Reverse) Signal Structure
Increase Signal
Minimum Required Settings for an Increase Signal
Example Increase Signal
Optional Settings for the Increase Signal
Increase Signal Structure
Reduce Signal
Minimum Required Settings for a Reduce Signal
Example Reduce Signal
Optional Settings for the Reduce Signal
Reduce Signal Structure
Close Signal
Minimum Required Settings for a Close Signal
Example Close Signal
Optional Settings for the Close Signal
Close Signal Structure
Reverse Signal
Minimum Required Settings for a Reverse Signal
Example Reverse Signal
Reverse Signal Structure
Pine Script
Related Articles
Types of Position Signals
- Open: Opens a new position (long or short).
- Increase: Increases the size of an existing position.
- Reduce: Decreases the size of an existing position.
- Close: Closes a specified position.
- Reverse (Futures Only): Closes the current position and opens a new position in the opposite direction.
Required Settings for All Signal Types
Each webhook signal must include the following settings:
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "open",
"exchange": "BYBI",
"symbol": "BYBI_USDT_SOL"
}
For a detailed list of valid exchange and symbol values, see: Webhooks: Valid Values for Exchange and Symbol.
Example Signal Including Only Settings Required for All Signals
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "close",
"exchange": "BYBI",
"symbol": "BYBI_USDT_SOL"
}
Open Signal
An Open signal is used to open a new position. For the signal to be received and executed, the following conditions must be met:
The API key and secret must match those in the Bot Settings.
The signal must be formatted in valid JSON.
The signal must meet all filter criteria in the Signal Bot settings.
Minimum Required Settings for an Open Signal
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "BYBI",
"symbol": "BYBI_USDT_SOL",
"action": "open",
"side": "long"
}
Apart from the 5 settings that are required for all Signal Types, (see above), the only additional setting that is required for an Open signal is "side"
For side valid options are long or short.
Use long for a position that opens with a Buy entry and closes with Sell exit/s.
Use short for a position that opens with a Sell entry and closes with Buy exit/s.
Short positions can be opened on Futures exchanges using the quote currency
Short positions can be opened on Spot exchanges if the coins (base currency) are already owned and available to be sold
Example of an Open signal including all required and optional settings:
{
"action": "open",
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "BYBI",
"symbol": "BYBI_USDT_SOL",
"side": "long",
"test": true,
"quote_amount": 100,
"order_type": "limit",
"signal_price": 22.5,
"signal_id": "unique_signal_id_123",
"leverage": 5,
"adjust_fee": true,
"dca_orders": [
{
"price_percentage": 5,
"quantity_percentage": 100
},
{
"price_percentage": 10,
"quantity_percentage": 200
}
],
"take_profit": [
{
"price_percentage": 3,
"position_percentage": 30
},
{
"price_percentage": 5,
"position_percentage": 40
},
{
"price_percentage": 8,
"position_percentage": 30,
"trailing_distance": 1.5
}
],
"stop_loss": {
"stop_percentage": 7,
"cool_down_amount": 10,
"cool_down_time_frame": "minute",
"cool_down_type": "TIME",
"cool_down_cancel_price": 20.5,
"protection_type": "PRICE",
"trailing_percentage": 5,
"trailing_distance": 1
},
"entry_expiration": {
"time": 60,
"price": 25
},
"entry_condition": {
"time": 5,
"price": 22,
"operator": "OR"
}
}
Optional Settings for the Open (and Reverse) Signal
Setting | Values | Notes |
---|---|---|
test | true or false | If true, creates pending orders instead of live orders. Note: "test": true will ONLY work with an Open signal. For other signal types, it will be ignored and a live order will be sent. |
action | open | Defaults to open. |
order_type | market or limit | Defaults to limit if omitted. |
signal_price | numeric value | The special Trading View variable "{{close}}" can be used to substitute the Close price from the candle. If signal_price is omitted, Altrady will substitute the current price. |
quote_amount OR base_amount | numeric value, optional. If used, overrides the Bot Settings for the entry size. | This is a fixed amount in quote or base currency, not a percentage of the account. If both settings (quote and base) are included in the signal, an error will occur. Note: For the pair BTC/USDT, BTC is the base currency, and USDT is the quote currency. |
signal_id | If included, must be a unique character string for each signal. | Generally only used with Pinescript. Can be included in the Open signal if it will be needed for updating the position later. If used, it should include a varying value that will ensure it is always unique, such as the TV variable {{time}}. If signal_ID is omitted, Altrady will generate a unique signal_ID. |
leverage | numeric value | Used for futures only. If included, the leverage value will overwrite leverage included in the Signal Bot Settings. |
adjust_fee | true OR false | Optional: defaults to true. Reduces the order size to allow for exchange fees. Recommended when the entry or position size uses 100% of the available balance; this can otherwise cause the order to fail due to an insufficient balance error after the exchange deducts fees from the wallet. false allows the initial order size to be maximised, as fees will not be removed at this point. |
dca_orders | The DCA settings block can be repeated up to 9 times, for a total of 10 entry orders (see example below). | To use the DCA values from the webhook Signal, select the "DCA from Signal" option in the Signal Bot Settings . Multiple DCAs can be included by repeating the DCA block (see example below). |
price_percentage | numeric value. Specify price_percentage or price. | The percentage below the average entry price for the order to be placed. |
price | numeric value. Specify price_percentage or price. | The fixed price for the DCA entry order to be placed. |
quantity_percentage | numeric value | The percentage of the initial entry order for this DCA (e.g., 200 represents 200% or 2x the entry order size). |
take_profit | The take_profit settings block can be repeated up to 10 times (see example below). | To use the TP values from the webhook Signal, in the Signal Bot Settings , Take Profit from Signal option must be selected. |
price_percentage | numeric value. Specify price_percentage or price. | The percentage above/below (long/short) the average entry price for the TP order to be placed. Either price or price_percentage must be used for all TP orders in a signal. They cannot be combined in one signal. |
price | numeric value. Specify price_percentage or price. | The actual price for the order to be placed. This will not change even when the average entry price changes. |
position_percentage | numeric value | The percentage of the position size for this order. |
trailing_distance | numeric value | If this setting is included, the last TP order will be a Trailing Take Profit order. This value sets the distance behind the TP price for the Stop price to trail. When triggered, a Market order will be placed to close the position. TTP is only available on the last TP. |
Stop Loss settings | Optional | Include this block to set a Stop Loss value in the Signal. To use the SL values from the webhook signal, select the SL from Signal option in the Signal Bot Settings . More details: Stop Loss Settings |
stop_percentage OR stop_price | Required if a Stop Loss block is included. | Stop %: The percentage below the signal price for the SL to be placed. Once placed, the Stop Price is fixed and does not vary with average entry price, OR Stop Price: specify a price. |
Cooldown Settings | Optional with Stop Loss. | See: SL cooldown for more details. |
cool_down_type | Determines which other settings must be included | Choose either TIME or CANDLE CLOSE. |
TIME | Specify a time_frame type (day, hour, minute), and a duration to combine with the type. | e.g., "cool_down_type": "TIME", "cool_down_time_frame": "minute", "cool_down_amount": 5. |
CANDLE_CLOSE | Specify the candle resolution (time-frame) in minutes: 1, 2, 3, 5, 10, 15, 30, 60, 120, 240, 360, 720, 1440. Maximum is 1440: 1 day. | e.g., "cool_down_candle_resolution": "30". |
Emergency Stop Loss | Optional with cooldown. Specify either a specific SL price or % from entry price. Like the initial SL, the ESL is fixed once placed. | "cool_down_cancel_price": 101.123 OR "cool_down_cancel_percentage": 25. |
Protection Settings | Optional with Stop Loss. | See: Smart Orders: Trailing Stop Loss comparison for more details. |
protection_type | Values: PRICE, BREAK_EVEN, FOLLOW_TAKE_PROFIT | Choose the type of Trailing Stop Loss (see above) to protect your position. The PRICE option will follow the price. |
trailing_price | Numeric. The price at which trailing will start. | Used with PRICE only. Specify either trailing_price or trailing_percentage. |
trailing_percentage | Numeric. The percentage from the entry price at which trailing will start. | Used with PRICE only. Specify either trailing_price or trailing_percentage. |
trailing_distance | Numeric. Percentage behind the trailing_price or trailing_percentage at which the stop price will follow. | Required with PRICE |
entry_condition | Include this block to set a price and/or time condition before the initial orders are placed. | See: Start Position at... |
time | Numeric. The number of minutes to be added to the current time before the position will open. | Until the position opens, no coins are reserved. |
price | Numeric. The price at which the position should be opened. | |
operator | AND or OR | If both time and price settings are used in the entry_condition block, choose whether both conditions should be met ( AND ) or just one condition should be met ( OR ). |
entry_expiration | Include this block to set a time or price when the unfilled position should be cancelled. | If both time and price are specified, when one of these conditions is met, the position will be cancelled. |
time | Numeric. The number of minutes to be added to the current time before the position will expire. | If set, overrides the expiry time setting in the Signal Bot Settings. See also: Smart Orders: Time-based Expiration / Entry Order Expiration . |
price | Numeric. The price at which the position should expire. | See: Smart Orders: Price-based entry expiration . |
Including TPs, DCAs or SL in the signal
DCAs, TP/s and SL for your signals can either be:
included in your webhook entry signal (see above). Useful when they will vary with each signal or each market.
specified in the Signal Bot Settings . Useful when they will not vary for each market and signal; or
added manually to your positions once they have opened. Useful for manual intervention, or when these values may vary, and the TV alert does not provide these details.
Choose Custom in the Bot Settings, to specifiy the value in the Bot.
Use Signal in the Bot Settings, to use the values provided in the signal.
Repeating the DCA block for more than one DCA
{
"dca_orders": [
{
"price_percentage": 5,
"quantity_percentage": 100
},
{
"price_percentage": 10,
"quantity_percentage": 200
},
{
"price_percentage": 20,
"quantity_percentage": 400
}
]
}
Repeating the TP block for more than one TP
TP position_percentages should add to 100. If the sum is less than 100%, the remaining amount will be included in the last TP.
{
"take_profit": [
{
"price_percentage": 2,
"position_percentage": 50
},
{
"price_percentage": 4,
"position_percentage": 30
},
{
"price_percentage": 6,
"position_percentage": 20
}
]
}
Adding a Trailing Take Profit to the last TP order
{
"take_profit": [
{
"price_percentage": 2,
"position_percentage": 60
},
{
"price_percentage": 5,
"position_percentage": 40,
"trailing_distance": 1.5
}
]
}
Stop Loss example: Simple Stop Loss
SL 7.5% from entry, with no cooldown
{
"stop_loss": {
"stop_percentage": 7.5
}
}
Stop Loss example with Candle Close Cooldown
Stop Loss (20% from entry) with 4 hour Candle Close cooldown and Emergency Stop Loss (35% from entry)
{
"stop_loss": {
"stop_percentage": 20,
"cool_down_type": "CANDLE_CLOSE",
"cool_down_candle_resolution": "240",
"cool_down_cancel_percentage": 35
}
}
Stop Loss example with Timer Cooldown
Fixed price SL at 2.79, with 10 minute Timer Cooldown, and Emergency Stop Loss (at 2.59 fixed price)**
{
"stop_loss": {
"stop_price": 2.79,
"cool_down_amount": 10,
"cool_down_time_frame": "minute",
"cool_down_type": "TIME",
"cool_down_cancel_price": 2.59
}
}
Stop Loss example with Timer Cooldown and Protection
Fixed price SL at 0.00000100, with 1 hour Timer Cooldown, and TSL>Follow Price, trigger price 3% above the entry price and trailing stop 1% below the trigger price (long position; note for a short position, the trigger price would automatically be below the entry price, and stop price above the trigger price)
{
"stop_loss": {
"stop_price": 0.000001,
"cool_down_amount": 1,
"cool_down_time_frame": "hour",
"cool_down_type": "TIME",
"protection_type": "PRICE",
"trailing_percentage": 3,
"trailing_distance": 1
}
}
Open Signal Structure
Open Signal
└── Base Parameters (required)
├── api_key: "YOUR_ALTRADY_API_KEY"
├── api_secret: "YOUR_ALTRADY_API_SECRET"
├── action: "open"
├── exchange: "EXCHANGE_CODE"
├── symbol: "MARKET_CODE"
└── side: "long" │ "short"
│
├── Order Parameters (optional)
│ ├── test: true │ false
│ ├── order_type: "market" │ "limit"
│ ├── signal_price: number │ "{{close}}"
│ └── ONE OF:
│ ├── quote_amount: number
│ └── base_amount: number
│
├── Entry Condition (optional)
│ ├── time: number (minutes)
│ ├── price: number
│ └── operator: "AND" │ "OR"
│
├── Entry Expiration (optional)
│ ├── time: number (minutes)
│ └── price: number
│
├── Take Profit Settings (optional array)
│ └── [
│ {
│ ├── ONE OF:
│ │ ├── price_percentage: number
│ │ └── price: number
│ ├── position_percentage: number
│ └── trailing_distance: number (last TP only)
│ },
│ {...} // Up to 10 TPs
│ ]
│
├── DCA Orders (optional array)
│ └── [
│ {
│ ├── ONE OF:
│ │ ├── price_percentage: number
│ │ └── price: number
│ └── quantity_percentage: number
│ },
│ {...} // Up to 9 DCAs
│ ]
│
└── Stop Loss Settings (optional)
├── Basic SL (ONE required)
│ ├── stop_percentage: number
│ └── stop_price: number
│
├── Cooldown Settings (optional)
│ ├── cool_down_type: "TIME" │ "CANDLE_CLOSE"
│ ├── IF "TIME":
│ │ ├── cool_down_time_frame: "minute" │ "hour" │ "day"
│ │ └── cool_down_amount: number
│ ├── IF "CANDLE_CLOSE":
│ │ └── cool_down_candle_resolution: "1" │ "5" │ "15" │ ... │ "1440"
│ └── Emergency SL (optional, ONE only)
│ ├── cool_down_cancel_price: number
│ └── cool_down_cancel_percentage: number
│
└── Protection Settings (optional)
├── protection_type: "PRICE" │ "BREAK_EVEN" │ "FOLLOW_TAKE_PROFIT"
├── IF "PRICE":
│ ├── ONE OF:
│ │ ├── trailing_price: number
│ │ └── trailing_percentage: number
│ └── trailing_distance: number
└── (other protection types have their own parameters)
Increase Signal
The Increase signal is used to increase the position size of one or more open positions, for a single market and side
It will increase the size of existing position/s for the specified market and side, that were opened by the Signal Bot.
Minimum Required Settings for an Increase Signal
Example of an Increase signal including minimum required settings:
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "increase",
"side": "long",
"exchange": "BINA",
"symbol": "BINA_USDT_BTC",
"increase_order": {
"quantity_percentage": 100
}
}
One increase_order block must be included, and only one.
"quantity_percentage" OR quote_amount OR base_amount This is a numeric value. Use ONE of these to specify the increase amount. If more than one is included, the signal is rejected. Note: for the pair BTC/USDT, BTC is the base currency and USDT is the quote currency.
.. "quantity_percentage"
increases the position size by a percentage of the initial entry order size. For example, set to 100 to increase the position size by the same amount as the initial entry order.
.. "quote_amount"
increases the position size by the amount of quote currency specified (rounded down to the highest possible order size).
.. "base_amount"
increases the position size by the amount of base currency specified (e.g. 250 would be specified for 250 ADA, for BIFU_USDT_ADA).
Example Increase Signal including required and optional settings
The example below uses the Trading View variable {{ close }} to insert the price at the candle close
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "increase",
"side": "long",
"exchange": "BINA",
"symbol": "BINA_USDT_BTC",
"increase_order": {
"base_amount": 25.5,
"order_type": "limit",
"price": "{{close}}"
}
}
Optional Settings for the Increase Signal
"order_type" is optional and can be "limit" or "market". If excluded, it will default to limit. For a limit increase order, "price" can be specified.
If "market" is used for "order_type", the order will be placed as a market order and the "price" field (if included) will be ignored.
`price `can be a numeric value, or a Trading View variable such as {{close}} (TV only).
Increase Signal Structure
Increase Signal
└── Base Parameters (required)
├── api_key: "YOUR_ALTRADY_API_KEY"
├── api_secret: "YOUR_ALTRADY_API_SECRET"
├── action: "increase"
├── exchange: "EXCHANGE_CODE"
├── symbol: "MARKET_CODE"
├── side: "long" | "short"
└── increase_order: {
├── ONE OF: (required)
│ ├── quantity_percentage: number
│ ├── quote_amount: number
│ └── base_amount: number
├── order_type: "limit" | "market" (optional, defaults to "limit")
└── IF "limit": price: number (optional)
Reduce Signal
The reduce signal is used to reduce the position size of one or more positions opened by the signal bot, for the specified market and side
reduce will partially close matching open positions by the amount specified in the signal.
Processing
Once the reduce signal is received by the bot, for each position that matches the signal symbol and side:
all open Take Profit orders are cancelled .
A new order is created for the specified amount in the reduce block
Each existing TP is reduced proportionally and placed again at the original price
For example:
Existing TPs at [price (%)]: 105 (20%), 115 (30%), 125 (50%)
A reduce signal to close 10% of the position at market price is received
New TPs: 10% (market order), limit orders at: 105 (18%), 115 (27%), 125 (45%)
Minimum Required Settings for a Reduce Signal
{
"action": "reduce",
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "BINA",
"symbol": "BINA_USDT_SOL",
"side": "long",
"reduce_order": {
"percentage": 25
}
}
"action": "reduce"
The API key and Secret must match those in the Bot Settings.
Exchange and Symbol must be specified.
One reduce_order block must be included, and must include the amount to close, either as a percentage of the open size, or an amount of base or quote currency.
Note that, only filled entry orders count in the open position size.
Order Size
"percentage" OR "quote_amount" OR "base_amount". This is a numeric value. Use ONE of these to specify the reduce amount. If more than one is included, the signal will be rejected. Note: for the pair BTC/USDT, BTC is the base currency and USDT is the quote currency.
.. percentage
reduces the position size by a percentage of the initial entry order size. For example, set to 100 to reduce the position size by the same amount as the initial entry order.
.. quote_amount
reduces the position size by the amount of quote currency specified (rounded down to the highest possible order size).
.. base_amount
reduces the position size by the amount of base currency specified (e.g. 250 would be specified for 250 ADA, for BIFU_USDT_ADA).
Example of a Reduce Signal including all required and optional settings
The example below creates a market TP order for 25.5 ADA.
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "reduce",
"side": "long",
"exchange": "BINA",
"symbol": "BINA_USDT_SOL",
"reduce_order": {
"base_amount": 25.5,
"order_type": "market"
}
}
Optional Settings for the Reduce Signal
"order_type" is optional and can be "limit" or "market". When used, order_type must be inside the reduce_order block (see above).
If excluded, order_type will default to limit. For a limit reduce order, price is optional.
If "market" is used for "order_type", the order will be placed as a market order.
price can be a numeric value or a Trading View variable such as {{close}} (TV only).
Reduce Signal Structure
Reduce Signal
└── Base Parameters (required)
├── api_key: "YOUR_ALTRADY_API_KEY"
├── api_secret: "YOUR_ALTRADY_API_SECRET"
├── action: "reduce"
├── exchange: "EXCHANGE_CODE"
├── symbol: "MARKET_CODE"
├── side: "long" | "short"
└── reduce_order: {
├── ONE OF: (required)
│ ├── percentage: number
│ ├── quote_amount: number
│ └── base_amount: number
├── order_type: "limit" | "market" (optional, defaults to "limit")
└── IF "limit": price: number (optional)
Close Signal
The Close signal is used to close running position/s for the specified market, that were opened by the same Signal Bot.
A signal with the close action will close the position/s regardless of whether any entry orders have been filled.
The following criteria must be met:
The API key and Secret must match those in the Bot Settings.
"action": "close" is required
Exchange and Symbol must be specified.
Minimum required settings for a Close signal
This signal would close all open long positions for XBT/USD, that were opened by the Signal Bot.
{
"action": "close",
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "KRKN",
"symbol": "KRKN_USD_XBT",
"side": "long",
"order_type": "limit",
"price": 30500
}
`action `must be close.
"order_type": "market"` or "order_type": "limit" is required for a close signal.
"order_type": "market" cannot be combined with "price". It will close the current position/s using a pseudo-market order (a limit order 10% from the current price).
"order_type": "limit" must be used with "price". It will close the position with a limit order at the specified price.
Example of a Close signal including all required and optional settings:
{
"action": "close",
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "KRKN",
"symbol": "KRKN_USD_XBT",
"side": "long",
"signal_id": "original_signal_id_123",
"order_type": "market"
}
Optional Settings for the Close Signal
side . If omitted, side will default to "long". The side refers to the side of the original position when it was opened. Either long positions or short positions can be closed with one signal, not both.
signal_ID If used, this must be the signal_ID of the signal that opened the specific position.
When the signal_ID is omitted, all positions for the specified market and side, and that were opened by the Signal Bot, will be closed.
Where there might be more than one position open for the same Symbol and Side, signal_ID is used to specify a specific position to close. Since it must match the signal_ID that opened the position, this is not possible with standard Trading View indicators. It might be possible to code using PineScript.
Note. If a Signal_ID was not specified with the original Signal, Altrady will have created a unique signal_ID for the signal. Trading View will not have access to an Altrady-generated Signal_ID
If your bot has a Setting of "Max per market" = 1 , then only one position will ever be opened for one market at the same time. In that case, the Close signal will close that single position, and the Signal_ID is not needed.
Close Signal Structure
Close Signal
└── Base Parameters (required)
├── api_key: "YOUR_ALTRADY_API_KEY"
├── api_secret: "YOUR_ALTRADY_API_SECRET"
├── action: "close"
├── exchange: "EXCHANGE_CODE"
├── symbol: "MARKET_CODE"
├── order_type: "market" | "limit" (required for close)
│ └── IF "limit": price: number (required)
├── side: "long" | "short" (optional, defaults to "long")
└── signal_ID: "ORIGINAL_SIGNAL_ID" (optional)
Reverse Signal
The Reverse signal can only be used for Futures markets.
Minimum settings for a reverse signal
The following example will close any existing short positions, and open a new long position for BTC/USDT on Binance.
{
"action": "reverse",
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "BINA",
"symbol": "BINA_USDT_BTC",
"side": "long"
}
Other than the "action": "reverse", all settings for the reverse signal are identical to the required and optional settings for the Open Signal .
The Reverse signal is like a combination of two signals in one: `close `and open.
close the existing position(s) with a market order and open a new position with the given parameters.
The new position will not be opened until the existing position is closed.
For side : valid options are "long" or "short". This will be the side of the new position created. If omitted, it will default to "long".
It will retry up to 5 times with a 3 second delay before failing. This happens asynchronously so the webhook will return immediately, Returns 204 no content when the request is successfully received, otherwise returns the same error messages as the open action.
Use of the Reverse signal is recommended over sending independent close and open signals. With separate signals, the timing of the close is unknown; if the close is not completed on the exchange before the open signal arrives, the Open signal will be ignored, unless hedge mode is enabled and two positions per market are allowed in the bot settings. Additionally, only one signal can be sent in a single TV alert message, so a second alert would be needed for the open signal.
If the position is already closed when the reverse action is received, it will just open a new position with the given settings.
Further details for the Reverse signal can be seen under Open Signal.
Reverse Signal Structure
Reverse Signal (Futures Only)
└── Base Parameters (required)
├── api_key: "YOUR_ALTRADY_API_KEY"
├── api_secret: "YOUR_ALTRADY_API_SECRET"
├── action: "reverse"
├── exchange: "EXCHANGE_CODE"
├── symbol: "MARKET_CODE"
└── side: "long" | "short" (side for new position)
|
└── Same optional parameters as Open Signal
├── Order Parameters
├── Entry Condition
├── Entry Expiration
├── Take Profit Settings
├── DCA Orders
└── Stop Loss Settings
For more details, see: Open (and Reverse) Signal Structure
Pine Script
For TradingView alerts, use the webhook URL: https://api.altrady.com/v2/signal_bot_positions.
To simply set up the creation of an order by price crossing or by crossing a trend line as above does not require any programming skills, but if you need to connect an indicator or a strategy, you will need basic knowledge of creating a signal in Pine Script. There is a lot of information on the web about how to generate a signal in Pine.
You can also search on, and ask for advice from, the Pine Scripters Telegram User Group .
TTP is only available on the last indicator("Altrady webhook signal")
test = input.bool(true, "Test signal")
api_key = input.string("", "Api key")
secret = input.string("", "Secret")
signal_name = input.string("", "Signal name")
side = input.string("", "Side")
exchange = input.string("", "Exchange name")
symbol = input.string("", "Symbol")
signal_price = close
alert('{"test": '+ str.tostring(test) +', "api_key": "'+api_key+'","api_secret": "'+secret+'","signal_id": "'+ signal_name + str.tostring(time)+'","side": "'+ side +'","exchange": "'+ exchange +'", "symbol": "'+ symbol +'","signal_price": "' + str.tostring(signal_price) +'"}')
alert('{"api_key": "YOUR_ALTRADY_API_KEY", "action": "open", "symbol": "BTCUSDT", "side": "long"}')
With "test": true, your webhook signal in combination with your bot, should create Pending orders that you can see on the chart and in My Orders.
Note: "test": true ONLY works with Open signals. For other signal types, this will be ignored and a live order will be sent.
Once you are ready to send live signals, change the first line to: test = input.bool(false, "Test signal")`

Please change the API Key and Secret and also make sure you set the correct exchange and symbol
Please ensure the Signal ID is unique per bot. Using the {{ time }} will ensure a unique signal ID each second ---
Related Articles
Webhook and Trading View Signals: Overview
Webhook: Setting up the Signal Bot
Webhook Signals: Webhook Builder
Webhook Signals: start or stop a Signal Bot
Valid values for Exchange and Symbol
Webhook Signals: Trading View Setup
Webhook Signals: Testing and Errors
Updated on: 20/03/2025
Thank you!