Signal Bot: Using the API with a Regular Signal Bot
An API is available for basic control of a regular (non-webhook) Signal Bot.
Currently, the API can be used to set the bot to Active or Inactive (i.e. to Start or Stop the bot).
The most common use case for stopping a signal bot is when conditions across the market become unfavourable for trading. In this scenario, the bot can be stopped automatically and then restarted either with a new signal or manually, when the conditions are right.
The most common way to send the signal uses an alert in Trading View based on a price change, indicator or strategy. When triggered, the alert sends a coded message with the bot's API key and secret to a specified url.
This is almost identical to the way Altrady's webhook bot works, with the following differences:
The url to receive the signal is different https://api.altrady.com/v2/signal_bot/start_stop
The JSON code is specific to non-webhook signal bots (details below) and can only start or stop the bot.
Create the Signal Bot using the Signals option.
Enable the API key section of the Settings.
Open a text editor such as Notepad.
Using word processing software to create or edit the JSON will create invalid code
Copy the JSON code below into the text editor.
"active": false will stop the bot.
"active": true will start the bot.
Copy/paste your API key and secret from the Signal Bot into the JSON code at the specified locations.
Save your Signal Bot. It will be running, status is active.
Test your code: On the Swagger test page :
please make sure you are using the /v2/signal_bot/start_stop "POST"
paste your JSON code in the white box
ensure the code includes "active": false
Click Try it out! . This will send an active signal to your bot.
Check for any errors.
Below, the Response Code will be 201 if the JSON message was successfully sent to the bot.
Possible errors are described here: Webhook Signals: Testing and Errors .
Fix any errors and try again.
Check the signal bot. First reload the page (Win: Ctrl+R. Mac: Cmd+R. Browser: page reload)
When your signal has stopped the bot, the bot will now offer the option to Start Bot
Set up the alert in Trading View to send the signal.
Choose the indicator to send the alert and add it to the chart if necessary.
The example used here is: BTC/USD price drop of 5% in 30 minutes or less. The signal will be sent as soon as the condition is met. (Note. this alert condition has been chosen purely for illustrative purposes.)
Choose the BTC/USD pair on the exchange of your choice.
Set the candle timeframe to 30 minutes.
Open the Alert dialog by: Clicking +Alert at the top of the chart, or entering Alt + A .
In the condition section at the top of the Alert dialog, for this example choose Moving Down %
enter 5
To test your Trading View alert, use a condition that is less stringent e.g. for the current example, 1% change in 1 hour. After confirming it's working as expected, change it to the real condition.
Select Once per Bar . The alert will be triggered as soon as the condition is met
Give the alert a name
Replace the text in the message box with your JSON code.
On the Notifications tab, enable Webhook URL
Paste the url: https://api.altrady.com/v2/signal_bot/start_stop
Click Create to save the Alert.
The Alert is now created.
Signal Bot Settings
Webhook and Trading View Signals: Overview
Webhook Signals: Testing and Errors
Currently, the API can be used to set the bot to Active or Inactive (i.e. to Start or Stop the bot).
The most common use case for stopping a signal bot is when conditions across the market become unfavourable for trading. In this scenario, the bot can be stopped automatically and then restarted either with a new signal or manually, when the conditions are right.
The most common way to send the signal uses an alert in Trading View based on a price change, indicator or strategy. When triggered, the alert sends a coded message with the bot's API key and secret to a specified url.
This is almost identical to the way Altrady's webhook bot works, with the following differences:
The url to receive the signal is different https://api.altrady.com/v2/signal_bot/start_stop
The JSON code is specific to non-webhook signal bots (details below) and can only start or stop the bot.
Create the Signal Bot using the Signals option.
Enable the API key section of the Settings.
Open a text editor such as Notepad.
Using word processing software to create or edit the JSON will create invalid code
Copy the JSON code below into the text editor.
{
"api_key": "YOUR API KEY",
"api_secret": "YOUR API SECRET",
"active": false
}
"active": false will stop the bot.
"active": true will start the bot.
Copy/paste your API key and secret from the Signal Bot into the JSON code at the specified locations.
Save your Signal Bot. It will be running, status is active.
Test your code: On the Swagger test page :
please make sure you are using the /v2/signal_bot/start_stop "POST"
paste your JSON code in the white box
ensure the code includes "active": false
Click Try it out! . This will send an active signal to your bot.
Check for any errors.
Below, the Response Code will be 201 if the JSON message was successfully sent to the bot.
Possible errors are described here: Webhook Signals: Testing and Errors .
Fix any errors and try again.
Check the signal bot. First reload the page (Win: Ctrl+R. Mac: Cmd+R. Browser: page reload)
When your signal has stopped the bot, the bot will now offer the option to Start Bot
Set up the alert in Trading View to send the signal.
Choose the indicator to send the alert and add it to the chart if necessary.
The example used here is: BTC/USD price drop of 5% in 30 minutes or less. The signal will be sent as soon as the condition is met. (Note. this alert condition has been chosen purely for illustrative purposes.)
Choose the BTC/USD pair on the exchange of your choice.
Set the candle timeframe to 30 minutes.
Open the Alert dialog by: Clicking +Alert at the top of the chart, or entering Alt + A .
In the condition section at the top of the Alert dialog, for this example choose Moving Down %
enter 5
To test your Trading View alert, use a condition that is less stringent e.g. for the current example, 1% change in 1 hour. After confirming it's working as expected, change it to the real condition.
Select Once per Bar . The alert will be triggered as soon as the condition is met
Give the alert a name
Replace the text in the message box with your JSON code.
On the Notifications tab, enable Webhook URL
Paste the url: https://api.altrady.com/v2/signal_bot/start_stop
Click Create to save the Alert.
The Alert is now created.
Related Articles
Signal Bots
Signal Bot Settings
Webhook Bots
Webhook and Trading View Signals: Overview
Webhook Signals: Testing and Errors
Updated on: 07/11/2024
Thank you!