This section will detail the steps to creating an Astrabit bot that can be connected to a custom strategy via webhooks
There is a functional difference between an Indicator and a Strategy
A Strategy is a type of script that offers a Backtest so users can see the actual trades and results that would've been taken, but by design has the tendency to repaint and give false signals if not coded correctly due to the usage of TradingView's backtesting engine directly generating signals
https://www.tradingview.com/pine-script-reference/v5/#fun_strategyStrategies MUST USE the Unified Signal endpoint on Astrabit (NOW LIVE!)
DCA Bots & Strategies are currently not compatible with the Unified Signal Endpoint
An Indicator is the other type of script that should NOT repaint and DOES have the ability to create customized alerts
https://www.tradingview.com/pine-script-reference/v5/#fun_indicator
Create a bot and go to Step One (Strategy)
Select the Personal Strategy tab and Enable the toggle to use bot with a personal strategy
Fill in the rest of your bot's allocations, type, and risk management settings
After creation you will see a window that shows your bot's Signal Notification URLs and your secret phrase to authenticate all requests
You can go to Edit your bot at any time to revisit and/or regenerate your Signal Notification URLs on Step Five (Connect your bot)
The URLs are webhook endpoints that expect the body message to have JSON containing the authentication secret
To confirm your JSON formatting please use a validation tool such as:
https://jsonlint.com/
Updating the alert Condition will set the next dropdown box to the default first item in the list of selections
If you update your indicator settings and want to update the alert with the new settings
The condition trigger must be updated after it's been reset to the default
Ex:
- Default condition trigger is "Long Close"
- Updating BTC Long alert and BTC Short alert
- Must change "Long Close" to "Long Open" for the Long Alert
- Must change"Long Close" to "Short Open" for the Short Alert
{
"code": "SOME_CODE_HERE",
"asset": "{{ticker}}",
"order_action": "{{strategy.order.action}}",
"order_price": "{{strategy.order.price}}",
"order_contracts": "{{strategy.order.contracts}}",
"isTest": false,
"current_position_size": "{{strategy.position_size}}",
"market_position": "{{strategy.market_position}}",
"market_position_size": "{{strategy.market_position_size}}",
"prev_market_position": "{{strategy.prev_market_position}}",
"prev_market_position_size": "{{strategy.prev_market_position_size}}"
}
Pinescript v5 Documentation
https://www.tradingview.com/pine-script-docs/en/v5/concepts/Alerts.html
Once Per Bar Close
and Once Per Bar
are the main options to use.Once Per Bar Close
will wait until the confirmation of candle closing to send the signal if your Condition is trueOnce Per Bar
will send the signal once during the candle's time such as when you need to send a Take Profit or Stop Loss level signal if your Condition is trueExpiration time
Tradingview has alert expirations unless you have a Premium account, the alert expiration can be continuously edited and updated manually for lower tier subscriptions
Alert Actions
This is where the webhook URL is inserted which will send the signal out from Tradingview to Astrabit
Alert Name
Convenient name to track your alerts and make sure you don't cross signals
Message
MUST contain JSON formatted payload and NO OTHER TEXT
to be parsed by Astrabit and confirm signal(s)
Validate JSON formatting at any online lint checker such as https://jsonlint.com/
{
"secret": "YOUR_SECRET_KEY_WILL_BE_HERE",
"order_price": "{{close}}",
"close": "50"
}
{
"code": "STRATEGY_CODE_HERE",
"asset": "{{ticker}}",
"price": "{{close}}",
"order_action": "{{strategy.order.action}}",
"order_price": "{{strategy.order.price}}",
"order_contracts": "{{strategy.order.contracts}}",
"isTest": false,
"current_position_size": "{{strategy.position_size}}",
"market_position": "{{strategy.market_position}}",
"market_position_size": "{{strategy.market_position_size}}",
"prev_market_position": "{{strategy.prev_market_position}}",
"prev_market_position_size": "{{strategy.prev_market_position_size}}"
}
Please reference the notes above for Tradingview
Summation
To test your signal setup from a personal bot to Astrabit is authenticating and being recieved correctly:
Create an alert for testing that uses the "Close Signal Notification URL"
Select the asset for the chart you're on (normally the first option)
Greater Than
Value: 0
Only Once
This will send a single test signal whenever it is saved, or each time it's enabled from the TV alerts sidebar
You can then check your personal bot's Signal Log and make sure that the close signal was received by Astrabit to execute on
Now you know that you can send signals and authenticate them now that the Alert Message is correct and can be copied and pasted to all other alerts for that strategy