Articles on: Signals and Automation

Webhook and Trading View signals

Webhook signals



In order to use the Signal Bot with custom signals, you will have to create a new Signal Bot and configure it with Webhook support.
An existing Signal bot cannot be Duplicated for your Webhook bot.

Please check the video about the Signal Bot Webhook setup (0:55 to 1:27).
The rest of the Signal Bot set up for webhooks is the same as for Signals.



For people with a developer background, you can reference the following API documentation for the Webhook.

https://api.altrady.com/v2/doc

TP/s for your signals can either be:
included in your entry signal
included your Bot Settings, or
added manually to your positions once they have opened.

Accepted values for exchange



Bittrex or BTRX
Binance or BINA
HitBTC or HITB
Poloniex or PLNX
Kucoin or KUCN
Huobi or HUBI
Kraken or KRKN
Coinbase Pro or GDAX
OKEx or OKEX
Binance US or BIUS
ByBit or BYBI
Bitvavo or BVVO
Gate.io or GATE

Accepted value for symbol



You can use the symbol format as used by the exchange API (e.g. BTCUSDT, BTC-USDT depending on the exchange)
OR
You can use the symbol in the format of <Exchange Code>_<Quote>_<Base> e.g. BINA_USDT_BTC
The Exchange codes are listed above.

Trading View setup



If you want to use Trading View for sending signals, you have 2 options.
You can set up an Alert or you can use a custom pine script to create a signal.

Alert



For the webhook URL, use:
https://api.altrady.com/v2/signal_bot_positions

And for testing the message you use:

{
  "test": true,
  "api_key": "<api_key>",
  "api_secret": "<secret>",
  "side": "long",
  "exchange": "binance",
  "symbol": "BINA_USDT_BTC",
  "signal_price": "{{close}}"
}


To edit the JSON code, use a text editor, not a word processing app

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, use:
"test": false,

Setup alert

Please change the API Key and Secret, leaving out the < and > symbols. Also make sure you set the correct exchange and symbol.

Signal Price is optional.
"signal_price": "{{close}}" will use the close price for the candle.
If omitted from the alert, Altrady will use the Current Price.

Your payload can be checked for syntax here.

For testing your syntax using the above link, you will need to replace {{ close }} with a valid number e.g. "signal_price": 5

Including TPs, DCAs or SL in the signal



If the DCAs, TPs, and SL will not vary with each signal, then it is simplest to specify them in the Signal Bot settings.
To specify different DCAs, TPs or SL depending on the signal, then the JSON code can include this.

This is the general format of the full JSON code, including DCAs, TPs and SL:
{

  "test": true,

  "api_key": "string",

  "api_secret": "string",
  "side": "long",
  "exchange": "string",
  "symbol": "string",
  "signal_price": 0,
  "take_profit": [
    {
      "price_percentage": 0,
      "position_percentage": 0
    }
  ],
  "dca_orders": [
    {
      "price_percentage": 0,
      "quantity_percentage": 0
    }
  ],
  "stop_loss_percentage": 0
}


The TP, DCA and SL sections can be replaced and duplicated as needed:

"take_profit": [
    {
      "price_percentage": 2,
      "position_percentage": 35
    },
    {
      "price_percentage": 4,
      "position_percentage": 65
    }
  ],
  "dca_orders": [
    {
      "price_percentage": 5,
      "quantity_percentage": 100
    },
    {
      "price_percentage": 12,
      "quantity_percentage": 200
    }
  ],
  "stop_loss_percentage": 35


The Signal Bot must also be configured to accept the DCAs, TPs, and/or SL from the Signal.
Turn on the relevant section, and Select the Signal option.

To use the values sent in the Signal, turn on the section in the Signal Bot and select &quot;Signal&quot;

Short or Sell Signals

Altrady's webhook can also be used to send a sell signal for coins already owned, or a to create a short (spot) position for coins already owned.
At the moment, the webhooks and signal bots are only available for Spot exchanges.

To sell coins already owned:
create a new Signal Bot to receive the signal.
The signal bot uses the quote currency of the market
The entry size is the amount or percentage of the base currency to sell.
For example, if you are trading ADA/USDT, the quote currency will be USDT, and the base currency is ADA.
If a percentage is specified, the bot will multiply that by the available balance of that coin, at the time the signal is received.
For example, if you own 100 ADA, 20 are reserved in orders, and you want to sell 40, then you would specify 40 coins, or 50%.

At the moment, it's not possible to link a signal to an open position. It is possible to buy or sell coins for the same market, based on a new signal.

You can use an Entry Price Deviation to increase the chance of the order filling quickly.
You will not need to specify DCAs, TPs or SL for a simple Sell signal.
To create a short position--with a Sell entry and optional DCAs, Buy TPs and SL, you can either include these in the Signal Bot or in the webhook, as for a Long/Buy position.

The JSON code:
As for your Buy webhook, copy the API key and secret and paste those into the JSON code for your Webhook Sell alert.
Change:
"side": "long",
to
"side": "short",
In Trading View, create your alert Sell signal using a Sell trigger.

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

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) +'"}')


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")

Pine script

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

Updated on: 25/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!