Webhook Signals: Open, Close, Increase or Reverse a Position
The Webhook Signals described in this section are related to positions on a Webhook-type Signal Bot.
A position can be opened, closed, increased or reversed using a webhook signal.
Example signal including only Settings required
Minimum Required Settings for an Open Signal
Example of an Open signal including all required and optional settings
Including TPs, DCAs or SL in the signal.
Repeating the DCA block for more than one DCA
Repeating the TP block for more than one TP
Stop Loss example: Simple Stop Loss
Stop Loss example with Candle Close Cooldown
Stop Loss example with Timer Cooldown
Stop Loss example with Timer Cooldown and Protection
Example Close signal, including only the minimum
Example Close signal including all required a
Required Settings specific to the Close Signal
Optional Settings for the Close Signal
Minimum settings for a reverse signal
Optional Settings for the Increase signal
Open : Open a new position, either short or long
Increase : Increase the size of an existing position (this will add a new entry order at the specified price)
Reverse : (Futures Only). Close the current position and create a new one with the side specified in the Signal
Close : Close current position/s for the specified market and side
Action The type of signal: open, close, reverse or increase
API key The API key from your Signal Bot
Secret The Secret from your Signal Bot
Exchange: See: Webhooks: Valid values for Exchange and Symbol
Symbol See: Webhooks: Valid values for Exchange and Symbol
Note that some Action types, have additional required settings.
The Open signal is used to open a new position for the chosen market.
For the signal to be received and opened, the following criteria must be met:
The API key and Secret must match those in the Bot Settings.
The syntax of the signal must be valid JSON
All filter criteria in the Signal Bot Settings must be matched by the signal.
Example of an open signal, including only the minimum required settings:
All other settings will be taken from 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 be below the entry price, and stop price above the trigger price)
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.
Exchange and Symbol must be specified.
"action": "close" is required
This signal would close all open long positions for XBT/USD, that were opened by the Signal Bot.
Details about the required settings are shown in Required Settings for all Signal Types
Details about the settings required for all signals can be found here: Required Settings for all Signal Types
"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 (this is 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.
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 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.
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 defailt 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. 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.
This will close any existing short positions, and open a new long position for BTC/USDT on Binance.
Further examples for the Reverse signal can be seen in the Open signal section
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.
The following criteria must be met:
The API key and Secret must match those in the Bot Settings.
Exchange and Symbol must be specified.
Example of an Increase signal including all required and optional settings. This example uses the Trading View variable {{ close }} to insert the price at the candle close
One increase_order block must be included, and only one .
Its two settings are:
"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 buy 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).
"price" is the limit order price for the increase position order. Optional : if the price is omitted., the current price will be used as the signal price. If set, the Entry Price Deviation in the Signal Bot Settings will adjust the signal price. This allows the Increase order to be specified as a pseudo-market order.
the Entry Price Deviation from the Signal Bot Settings is used to adjust the signal price for Increase signals. This works in the same way as for Open signals, and initial orders.
"side" is optional. If omitted, the side will default to long.
within the increase order block (above), "price" is optional.
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 .
For the webhook URL you use https://api.altrady.com/v2/signal_bot_positions
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.
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: start or stop a Signal Bot
Valid values for Exchange and Symbol ]
Webhook Signals: Trading View Setup
Webhook Signals: Testing and Errors
A position can be opened, closed, increased or reversed using a webhook signal.
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
Including TPs, DCAs or SL in the signal.
Repeating the DCA block for more than one DCA
Repeating the TP block for more than one TP
Stop Loss example: Simple Stop Loss
Stop Loss example with Candle Close Cooldown
Stop Loss example with Timer Cooldown
Stop Loss example with Timer Cooldown and Protection
Close Signal
Example Close signal, including only the minimum
Example Close signal including all required a
Required Settings specific to the Close Signal
Optional Settings for the Close Signal
Reverse Signal
Minimum settings for a reverse signal
Increase Signal
Optional Settings for the Increase signal
Related Articles
Types of Position Signals
Open : Open a new position, either short or long
Increase : Increase the size of an existing position (this will add a new entry order at the specified price)
Reverse : (Futures Only). Close the current position and create a new one with the side specified in the Signal
Close : Close current position/s for the specified market and side
Required Settings for all Signal Types
Action The type of signal: open, close, reverse or increase
API key The API key from your Signal Bot
Secret The Secret from your Signal Bot
Exchange: See: Webhooks: Valid values for Exchange and Symbol
Symbol See: Webhooks: Valid values for Exchange and Symbol
Example signal including only Settings required for all signals.
Note that some Action types, have additional required settings.
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"action": "close",
"exchange": "BYBI",
"symbol": "BYBI_USDT_SOL"
}
Open Signal
The Open signal is used to open a new position for the chosen market.
For the signal to be received and opened, the following criteria must be met:
The API key and Secret must match those in the Bot Settings.
The syntax of the signal must be valid JSON
All filter criteria in the Signal Bot Settings must be matched by the signal.
Minimum Required Settings for an Open Signal
Example of an open signal, including only the minimum required settings:
All other settings will be taken from the Signal Bot Settings.
{
"api_key": "YOUR_ALTRADY_API_KEY",
"api_secret": "YOUR_ALTRADY_API_SECRET",
"exchange": "EXCHANGE CODE",
"symbol": "MARKET CODE",
"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": "EXCHANGE CODE",
"symbol": "MARKET CODE",
"side": "long",
"test": true,
"quote_amount": 0,
"signal_id": "string",
"leverage": 0,
"signal_price": 0,
"adjust_fee": true,
"dca_orders": [
{
"price_percentage": 0,
"price": 0,
"quantity_percentage": 0
}
],
"take_profit": [
{
"price_percentage": 0,
"price": 0,
"position_percentage": 0,
"trailing_distance": 0
}
],
"stop_loss": {
"stop_percentage": 0,
"stop_price": 0,
"cool_down_amount": 0,
"cool_down_time_frame": "minute",
"cool_down_type": "TIME",
"cool_down_candle_resolution": "0",
"cool_down_cancel_price": 0,
"cool_down_cancel_percentage": 0,
"protection_type": "NONE",
"trailing_price": 0,
"trailing_percentage": 0,
"trailing_distance": 0
},
"entry_expiration": {
"time": 0,
"price": 0
},
"entry_condition": {
"time": 0,
"price": 0,
"operator": "OR"
},
}
Optional Settings for the Open (and Reverse) Signal
Setting | Values | Notes |
---|---|---|
test | true or false | Defaults to false. When test is true, the Position will open Pending orders instead of Live orders. Use this for testing signals. |
action | open | Defaults to open. |
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 | If included, the leverage value will overwrite leverage included in the Signal Bot Settings. |
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. Note that Entry orders are always limit orders. To simulate a Market order, use a positive Entry Price Deviation in the Signal Bot Settings . |
adjust_fee | true OR false | Optional: If omitted, defaults to true. If included, adjusts the entry order size to ensure there is enough to pay 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. |
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 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: FOLLOW_PRICE, BREAK_EVEN, FOLLOW_TAKE_PROFIT | Choose the type of Trailing Stop Loss (see above) to protect your position. |
trailing_price | Numeric. The price at which trailing will start. | Used with FOLLOW_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 FOLLOW_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 FOLLOW_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 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": "FOLLOW_PRICE",
"trailing_percentage": 3,
"trailing_distance": 1
}
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.
Exchange and Symbol must be specified.
"action": "close" is required
Example Close signal, including only the minimum required settings
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",
"order_type": "market",
"side": "ORIGINAL SIDE"
}
Details about the required settings are shown in Required Settings for all Signal Types
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": "EXCHANGE CODE",
"symbol": "MARKET CODE",
"side": "ORIGINAL SIDE",
"signal_ID": "ORIGINAL SIGNAL ID",
"order_type": "limit",
"price": 99
}
Required Settings specifically for the Close Signal
Details about the settings required for all signals can be found here: Required Settings for all Signal Types
"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.
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 (this is 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.
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 at the same time. In that case, the Close signal will close that single position, and the Signal_ID is not needed.
Reverse Signal
The Reverse signal can only be used for Futures markets.
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 defailt 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. 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.
Minimum settings for a reverse signal
This 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"
}
Further examples for the Reverse signal can be seen in the Open signal section
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.
The following criteria must be met:
The API key and Secret must match those in the Bot Settings.
Exchange and Symbol must be specified.
Example of an Increase signal including all required and optional settings. This example 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,
"price": "{{close}}"
}
}
Required settings
One increase_order block must be included, and only one .
Its two settings are:
"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 buy 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).
"price" is the limit order price for the increase position order. Optional : if the price is omitted., the current price will be used as the signal price. If set, the Entry Price Deviation in the Signal Bot Settings will adjust the signal price. This allows the Increase order to be specified as a pseudo-market order.
the Entry Price Deviation from the Signal Bot Settings is used to adjust the signal price for Increase signals. This works in the same way as for Open signals, and initial orders.
Optional Settings for the Increase signal
"side" is optional. If omitted, the side will default to long.
within the increase order block (above), "price" is optional.
Pine Script
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 .
For the webhook URL you use https://api.altrady.com/v2/signal_bot_positions
TTP is only available on the lastindicator("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) +'"}')
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.
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: start or stop a Signal Bot
Valid values for Exchange and Symbol ]
Webhook Signals: Trading View Setup
Webhook Signals: Testing and Errors
Updated on: 17/11/2024
Thank you!