Articles on: Signals and Automation

HODL Bot (using Altrady's Webhook)

This is a method to use Altrady's webhook Signal Bot as a HODL bot.
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
How to create the Spot position.

Set up the Signal Bot


Create a new Signal Bot



Enter the basic details
A name for the bot (user defined)
Copy the API key and Secret to a temporary location such as a text editor (such as Notepad).
Choose the exchange (Spot only)
Choose the trading account. This can be a paper trading account if preferred.
Choose the quote currency for buying coins e.g. USDT



Enter the maximum number of concurrent positions and maximum per market. These should be large numbers unless you want to stop buying after a set number of entries.



Enter the amount to spend on each order, either a fixed amount or percentage. The percentage would be used at the time a signal is received and multiplied by the available balance of quote currency in the account.
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, you can use an Entry Price Deviation to increase the entry price. For example, use 2 to multiply the order price by 1.02. The order will still be filled at the best prices in the order book, with the maximum price being the 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


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

Copy the following code into the editor:
{
  "test": true,
  "api_key": "<key here>",
  "api_secret": "<secret here>",
  "side": "long",
  "exchange": "binance",
  "symbol": "BINA_USDT_BTC"
}


Edit the code with your own details.
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:
exchange code
quote currency
base currency
If you are not sure, look up the market in Altrady to get the 4 character exchange code, as well as the base and quote currency codes.
Save your code

Here is an example for buying ADA with BTC on Kucoin:
{
"test": true,
"api_key": "92486a14-e060-46ec-860c-81e09623478",
"api_secret": "17f5de5e-b234-4eff-99eb-c0e654cb6b22",
"side": "long",
"exchange": "KUCN",
"symbol": "KUCN_BTC_ADA"
}

"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

Create the Webhook alert


Log into TV
Navigate to the chart for the market you want to buy (or sell)
Choose the 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 anywhere on the chart to open the context menu. Select Add alert.|



The dialog 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 JSON code here.



Check that your settings looks 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
click Save



Testing the Webhook and Bot


Testing options include:
using an Altrady paper account
with "Test": true--a pending order will be placed instead of live order
Use Once per Bar as the Trigger, so fire the alert as soon as you save the Alert. 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.

How to HODL more than one coin?


If you want to spend the same amount on each coin, and buy with the same quote currency, then the same signal bot can be reused for another coin.
So I could buy $100 of ETH every month and $100 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, and the same API key and secret in the JSON code.

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 alert 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

Analytics


Since the Signal Bot was designed for a different purpose we will need to do one step to set up analytics.
Each signal will create a new Bot Position in Altrady. These can be ignored or even deleted.
Instead, once your first order has filled, create a new Spot Position in the Position Info widget, for automatically generated analytics.
All filled orders for the market will be included in this position.
You will be able to see the average entry price and the PnL both in the Position Info widget and on the chart.

The line with a box indicates the average entry price and the current PnL % (red for loss, green for profit)

How to create the Spot position.

This can be created at any time after the first order has filled.
Select the relevant market. For this example it will be BINA: BTC/USDT
Locate the Position Info widget.
Open the Positions Dropdown list.


There will be an entry for each signal sent so far.
Click Create position



Click Start to select the date of the first filled order.



Then click the Save icon.
The Position Info widget shows detailed PnL and analytical information for all of the filled orders on this market, starting from the first order.



Each order will also create a Signal Bot Position. These are listed in My Positions and in your Signal Bot.



HODL Bot positions on ETH/USDT using a timeframe of 2 hours

More Information:


Webhook and Trading View signals

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: 13/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!