Articles on: Signals and Automation

HODL Bot (using Altrady's Webhook)

This is a method to use Altrady's webhook Signal Bot to accumulate coins.
A HODL bot (sometimes called a DCA bot) is for buying (or selling) tokens on a set schedule over a period of time.
The entry price is therefore averaged over time and it can also be a useful form of saving.

Contents


Set up the Signal Bot
Prepare the webhook code
Create the webhook
Testing the Webhook and Bot
How to HODL more than one coin?
Tracking your Orders
Analytics


Set up the Signal Bot


A Signal Bot will be used to receive the webhook signals, place orders, create positions, and report analytics.
The Signal Bot Settings specify the trading account (exchange account) and quote currency to use, as well as the entry order size.

Create a new Signal Bot



Enter the basic details
Copy the API key and Secret to a temporary location such as a text editor (such as Notepad). This will be used in your webhook signals so they are sent to the correct bot.
Choose the trading account. This can be a paper trading account for testing purposes, if preferred.
Choose the quote currency for the pair/s your bot will be trading, e.g. USDT
A name for the bot (user-defined)



Enter the maximum number of concurrent positions and maximum per market. This should be set to 1, as the bot will only have 1 position running, and the same position will be used to accumulate coin with multiple orders.



Enter the amount to spend on the initial order: either a fixed amount, or percentage of the available balance.
When the signal to buy is received, the order will be entered at the current price. If you wish to ensure that the buy will be filled quickly, you can use an Entry Price Deviation to increase the entry price. For example, use 2 to add 2% to the order price. The order will still be filled at the best prices in the order book, with the maximum price being 2% above the current price. Use a larger value for EPD for your order to be treated essentially as a market order.



Turn off the Take Profit section.
Click Save.



Prepare the webhook code


Two sets of webhook code are needed.
The first is for the open signal, which starts the position, and places the initial entry order. This signal is only used once.
The second is for the regular orders to be placed on a schedule. This requires "increase" signal, which will increase the size of the position that is already open.
The two sets of code are very similar.

Open a text editor, such as the one you used to record your API key and secret for the signal bot.

Copy the following two sets of code into the editor:

The Open signal

{
  "test": true,
  "action": "open",
  "api_key": "<key here>",
  "api_secret": "<secret here>",
  "side": "long",
  "exchange": "binance",
  "symbol": "BINA_USDT_BTC"

}

The Increase signal

{
  "test": true,
  "action": "increase",
  "api_key": "<key here>",
  "api_secret": "<secret here>",
  "side": "long",
  "exchange": "binance",
  "symbol": "BINA_USDT_BTC",
  "increase_order": {
   "quantity_percentage": 100
   }
}


Edit both sets of code code with your own details. (More details on the Increase signal here)
insert your API key and secret
Side "long" is used to buy coins
Replace "binance" with the name or Altrady code for your exchange. These are listed here. Case insensitive.
Replace the symbol with the code for the market. The three parts are (in order):
exchange code
quote currency
base currency
Specify the amount of the increase, either as a percentage of the initial order, a quote currency amount, or a base currency amount. Details here.
Save your two sets of code
"test": true is used during the testing phase and results in Pending orders being placed by the bot instead of live orders.

Here is an example for buying ADA with USDT on Kucoin.

Open

{
  "test": true,
  "action": "open",
  "api_key": "92486a14-e060-46ec-860c-81e09623478",
  "api_secret": "17f5de5e-b234-4eff-99eb-c0e654cb6b22",
  "side": "long",
  "exchange": "KUCN",
  "symbol": "KUCN_USDT_ADA"
}


Increase

{
  "test": true,
  "action": "increase",
  "api_key": "92486a14-e060-46ec-860c-81e09623478",
  "api_secret": "17f5de5e-b234-4eff-99eb-c0e654cb6b22",
  "side": "long",
  "exchange": "KUCN",
  "symbol": "KUCN_USDT_ADA",
 "increase_order": {
   "base_amount": 25.5
  }
}


"test": true is used for testing the code and the signals. When this is set, Pending orders will be created in Altrady instead of Live orders. Change true to false once you are ready to create live orders.

Testing the JSON code and sending the Open signal


First, check your JSON code to ensure it has no syntax errors.
Open Swagger and scroll down to find the code entry field (see image below).
Paste the JSON code for your Open signal, ensure that "test": true in your code, and click Try it Now.
A code of 201 means that the syntax was correct, and your bot was found.
Errors are shown further down the Swagger page. Refer for details of common errors.

Once the code for the Open signal is correct and you are ready to open your HODL position and place the first order:
Cancel any Pending orders created by the test signals and delete any open positions in the signal Bot
In your JSON, change "test": true to "test": false
click "Try It Now" again.
A position should be opened (check the Signal Bot Overview tab) and a live order should be placed on the exchange.
If either of these did not occur, check the Signal Bot Error Log. Errors are shown in this log when the signal data did not match the signal bot filter settings.
Other errors (e.g. order size is too small) are shown in the Push Notifications for the account.

Once the Open signal has succeeded and a position opened, the Increase signal can be tested in Swagger with "test": true.
Once the syntax is correct, the next step is to include the Increase signal in a Trading View webhook alert to be sent to the Signal Bot periodically (see below).



Create the Webhook alert


Log into Trading View
Navigate to the chart for the market you want to buy (or sell)
Choose the chart timeframe to suit the frequency you want to buy at e.g. 1d, 1w, 1m, 3mth
Add the RSI indicator to your chart. We will use the condition RSI > 0 to create the alert.
Since RSI is always greater than zero, the alert will always fire at the right time.



Right-click on an empty part of the chart to open the context menu. Select Add alert.



The dialog box for creating your webhook will now open.
From the first dropdown, select RSI



From the second dropdown choose Greater Than



Type 0 for the value



A bar is another name for a candle.
Once per Bar Close. If the chart is 1 week timeframe then the alert will be sent once per week at the end of the week.
Once per Bar. The alert will fire as soon as it is saved, and then once per week at the start of the week.
The start of the week and the end of the week are only 1 minute apart. So the main difference is whether you want the signal to fire immediately as well as once per week. This is useful for testing.
The default expiry date is one month in the future, so change this to the desired date, when you want to stop buying coins. With a Premium plan, the alert period can be open-ended. With the Pro or Pro+ Trading View plan, the expiry date can be a maximum of 2 months in the future. If you want to keep buying beyond that, set a reminder to yourself to extend the date once your expiry is reached.



A user-defined name for this alert
Remove the default message and copy your Increase signal JSON code here.
The Open signal JSON code will only be used once, so it does not need a recurring alert. Instead it can be sent from our testing page (see below).



Check that your settings look like these (with your own API key and secret)
Then swap to the Notifications tab.



Tick Webhook URL
copy this url into the entry field underneath:
https://api.altrady.com/v2/signal_bot_positions
Optionally, tick any of the other notification options to receive a notification each time the alert fires
click Create



Testing the Webhook and Bot


Testing options include:
using an Altrady paper account
with "Test": true--a pending order will be placed instead of a live order
Use Once per Bar as the Trigger, to fire the alert as soon as you save it. See #4 above

When you have finished testing:
delete any test alerts in Trading View, and set your Trigger to the desired timing (see #4 above)..
Change the JSON code in the message to:
"test": false,
This will now place live orders on your account.

More details: Webhook Signals: Testing and Errors

How to HODL more than one coin?


If you want to buy each coin using the same quote currency, on the same exchange, then the same signal bot can be used.
So I could buy $100 of ETH every month and $200 of BTC every week using the same signal bot.
All that is required is a new alert in Trading view, using the desired chart timefame, the same API key and secret in the JSON code.
If the order size is the same for each pair (e.g. 100 USDT), then this can be specified in the Signal Bot entry settings.
If different order sizes are required, this must be included in the signal, and will override the entry setting See Webhook Open, Close, Increase or Reverse: Open signal, for how to specify quote_amount OR base_amount for the First signal.
Then see: Webhook Open, Close, Increase or Reverse: Increase signal for how to specify the increase amount.

A new alert must be created in Trading view:
select the ETHUSDT chart on Binance
choose the 1 month timeframe
follow the same directions above, replacing the market with BINA_USDT_ETH
and save.
Your second HODL bot is ready to go.

Tracking Your Orders


While testing with "test": true, you will see the Open Pending orders in My Orders widget.
Once your alerts are sending Live signals, you will see the closed Orders under the Closed Orders tab.
You can also set notifications if you wish to be notified of each trade as it occurs.

Testing with 5m signals on a paper account

Tracking Your Position


With the above set-up, you will see that the bot opens a position that can be viewed in the Signal Bot Overview (basic details) and in the My Positions widget.
You can filter My Positions by position type and account, to help find your positions more easily.
This position will remain open until all of the coins are sold.
In the Position Info widget, view more detailed analytics for your HODL positions, including total investment, average entry price, Unrealised PnL, and number of trades.



More Information


Webhook and Trading View Signals: Overview

If you have questions about setting up a HODL bot using a Webhook, or anything else, please contact our Customer Support using the link at the bottom of this page.

Updated on: 15/10/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!